Unable to locate element with ID: identifierId when automating gmail with selenium using jmeter

42 views
Skip to first unread message

Maneesha Wijesekara

unread,
Jun 6, 2018, 10:32:56 PM6/6/18
to Selenium Users

Hi All,

I'm automating gmail login with selenium webdriver using jmeter but when executing the script, I'm getting the following error message with HTTP 500 status code,

Response message: Unable to locate element with ID: identifierId
For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html
Build info: version: '3.8.1', revision: '6e95a6684b', time: '2017-12-01T19:05:32.194Z'
System info: host: 'dhcppc4', ip: '192.168.1.104', os.name: 'Linux', os.arch: 'amd64', os.version: '4.4.0-127-generic', java.version: '1.8.0_161'
Driver info: driver.version: HtmlUnitDriver

Below is the snippet of the code,


import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.htmlunit.HtmlUnitDriver;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.support.ui.*;
import java.lang.String;
import java.util.concurrent.*;
import com.gargoylesoftware.htmlunit.*;
import com.gargoylesoftware.htmlunit.BrowserVersion;


try {
 
public HtmlUnitDriver driver = new HtmlUnitDriver(BrowserVersion.CHROME, true);
 driver
.manage().timeouts().implicitlyWait(60,TimeUnit.SECONDS);
 
String protocole = "http://";
 
String tomcathost = vars.get("tomcatHost");
 
String seperator = ":";
 
String tomcatport = vars.get("tomcatPort");
 
String url = "/travelocity.com/index.jsp";


 
String appURL = protocole + tomcathost + seperator + tomcatport + url;
 
 driver
.get(appURL);

       
WebElement link = driver.findElement(By.linkText("here"));

        link
.click();


Thread.sleep(5000);
       
     
String currentURL = driver.getCurrentUrl();
     
System.out.println(currentURL);


       
WebElement email_phone = driver.findElement(By.id("identifierId"));

        email_phone
.sendKeys("te...@gmail.com");
        driver
.findElement(By.id("identifierNext")).click();


        driver
.manage().timeouts().implicitlyWait(20,TimeUnit.SECONDS);


       
WebElement password = driver.findElement(By.xpath("//input[@name='password']"));
       
WebDriverWait wait = new WebDriverWait(driver, 20);
        wait
.until(ExpectedConditions.elementToBeClickable(password));
        password
.sendKeys("test@123");
        driver
.findElement(By.id("passwordNext")).click();
        driver
.manage().timeouts().implicitlyWait(20,TimeUnit.SECONDS);
 
//Returns the whole page
 
return driver.getPageSource();  
   
} catch (Exception ex) {
    ex
.printStackTrace();
    log
.error(ex.getMessage());
     
SampleResult.setSuccessful(false);
     
SampleResult.setResponseCode("500");
     
SampleResult.setResponseMessage(ex.getMessage());
}

I have a webapp that's hosted in a tomcat server and once after clicking the 'here' button it will redirect to gmail login (enter email) screen. I've verified the page when error occurs by printing the currentURL and web app directs to gmail login successfully.

According to the error, selenium automation failed to find the element 'identifierId' (email of the google login page) while do the automation. 

Any help to solve this would be highly appreciated.

Thanks and Regards
Maneesha
Reply all
Reply to author
Forward
0 new messages