+ Start a Discussion
sumit suwalkasumit suwalka 

selenium testing for lookup combo box

Hi All,
i am trying to automate a lightning component . i write a script for it .
but i have a lookup field on it i dont know how to test it?
my script is given below:-
package myPackage;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;

public class FamilyRecords {
    public static void main(String[] args) {
         // declaration and instantiation of objects/variables
        System.setProperty("webdriver.chrome.driver","C:\\Users\\user\\Downloads\\Chromedriver_win32\\chromedriver.exe");
        WebDriver driver = new ChromeDriver();
        String baseUrl = "https://login.salesforce.com";
        driver.get(baseUrl);
        driver.findElement(By.id("username")).sendKeys("kmalek@fbgholdings.com.sfdcadmin");                        
        driver.findElement(By.id("password")).sendKeys("2&*ZMRrGFSx&");                        
        WebElement login = driver.findElement(By.id("Login"));
        login.submit();
        driver.navigate().to("https://fbg--sfdcadmin.lightning.force.com/lightning/r/Account/001S000000zb9KyIAI/view?0.source=alohaHeader");
        WebElement newpage = driver.findElement(By.cssSelector(".slds-button, .slds-button_neutral, .buttonStyle"));
        newpage.click(); 
        //driver.manage().timeouts().implicitlyWait(10,TimeUnit.SECONDS);
        driver.navigate().to("https://fbg--sfdcadmin.lightning.force.com/lightning/o/FBG_Family__c/new?nooverride=1&backgroundContext=%2Flightning%2Fr%2FAccount%2F001S000000zb9KyIAI%2Fview%3F0.source%3DalohaHeader&0.source=alohaHeader");
        System.out.println("click submit");
        WebDriverWait wait=new WebDriverWait(driver, 20);
        WebElement namefield = wait.until(
                ExpectedConditions.visibilityOfElementLocated(By.id("5998:0")));
        namefield.sendKeys("June12");
        WebElement namefield2 = wait.until(
                ExpectedConditions.visibilityOfElementLocated(By.id("6103:0")));
        namefield2.sendKeys("June12");
        WebElement Accsubmit = driver.findElement(By.cssSelector(".slds-button, .slds-button--neutral, .uiButton--brand, .uiButton, .forceActionButton"));

        Accsubmit.click();
        System.out.println("record submit");
        WebElement option1 =  driver.findElement(By.cssSelector(".slds-checkbox_faux"));                            
        //This will Toggle the Check box         
        option1.click();    
        driver.close();
        
    }
}User-added image
 
Khan AnasKhan Anas (Salesforce Developers) 
Hi Sumit,

Greetings to you!

I'm afraid I wasn't able to find much regarding this issue. Here are some related discussions which hopefully may be able to guide you somehow:

https://developer.salesforce.com/forums/?id=9060G000000XjGKQA0

https://developer.salesforce.com/forums/?id=9060G000000BifZQAS

I hope it helps you.

Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.

Thanks and Regards,
Khan Anas
sumit suwalkasumit suwalka
Hi Khan,
i am testing lightning component with selenium. i have lightning tab on it below is the given imageUser-added image
when i am trying to find this tab from selenium its givig me error of no such element.
  WebElement Family = driver.findElement(By.cssSelector(".tablist, .tabs__nav, .tabs__item active, .uiTabItem"));
   Family.click(); 

the HTML is given below for this:-<span class="title" data-aura-rendered-by="1284:0">Family Records</span>
i tried with  this  too :-driver.findElement(By.cssSelector(".title")); but still showing me the same error?

how to solve this ?
Any suggestions