0

I am trying selenium webdriver for the first time. Want to login in gmail and wrote a program for the same. The code is providing the email id and proceeding further, but it is not entering the password. PFB my program. Can someone help on this?

System.setProperty("webdriver.chrome.driver", "C:\\Selenium Jar Files\\Selenium Jar Files\\chromedriver.exe");
        WebDriver driver = new ChromeDriver();
        driver.get("https://www.google.co.in/");
        String i = driver.getTitle();
        System.out.println(i);
        driver.findElement(By.linkText("Gmail")).click();
        driver.findElement(By.id("Email")).sendKeys("abc@gmail.com");
        driver.findElement(By.id("next")).click();
        driver.switchTo().frame("gaia_loginform");
        driver.findElement(By.id("Passwd")).sendKeys("abc@123");
        driver.findElement(By.id("signIn")).click();
Qwerty
  • 1
  • 4

1 Answers1

0

Gmail login fail using Selenium webdriver. Showing element not found for password

Explanation

The reason selenium can't find the element is because the id of the password input field is initially Passwd-hidden. After you click on the "Next" button, Google first verifies the email address entered and then shows the password input field (by changing the id from Passwd-hidden to Passwd). So, when the password field is still hidden (i.e. Google is still verifying the email id), your webdriver starts searching for the password input field with id Passwd which is still hidden. And hence, an exception is thrown."

Community
  • 1
  • 1