Home > Enterprise >  Unable to handle the Login page on naukri.com
Unable to handle the Login page on naukri.com

Time:10-17

I am trying to do the login and its not working giving error on accessing enter image description here

CodePudding user response:

The locators you are using it here :

 WebElement username = wait.until(ExpectedConditions.visibilityOfElementLocated((By.xpath("//input[@plcaeholder='Enter your active Email ID / Username']"))));
 WebElement password = wait.until(ExpectedConditions.visibilityOfElementLocated((By.xpath("//input[@plcaeholder='Enter your password']"))));

looks brittles since they are totally dependent on placeholder text.

Please use below locator :

for username :

//label[contains(text(),'Username')]//following-sibling::input

for password :

//label[contains(text(),'Password')]//following-sibling::input

Your code should look like this :

WebElement username = wait.until(ExpectedConditions.visibilityOfElementLocated((By.xpath("//label[contains(text(),'Username')]//following-sibling::input"))));
WebElement password = wait.until(ExpectedConditions.visibilityOfElementLocated((By.xpath("//label[contains(text(),'Password')]//following-sibling::input"))));
username.sendKeys("[email protected]");
password.sendKeys("123456");
  • Related