I was just trying to automate the Gmail login process using Selenium WebDriver...After the email id is entered a new page opens to enter the password. How do I enter the password?
WebElement element= driver.findElement(By.xpath("//*[@id='ident']"));
element.sendKeys("THE EMAIL ID");
element.sendKeys(Keys.ENTER);
WebElement ele= driver.findElement(By.xpath("//*[@id='passd']"));
ele.sendKeys("THE PASSWORD");
ele.sendKeys(Keys.ENTER);
You have to switch the driver to current handler.
Please use below code to enter password.
WebElement element= driver.findElement(By.xpath("//*
[@id='ident']"));
element.sendKeys("THE EMAIL ID");
element.sendKeys(Keys.ENTER);
String mainWindowHandler = driver.getWindowHandle();
for(String winHandle : driver.getWindowHandles()) {
if (!mainWindowHandler.equals(winHandle)) {
driver.switchTo().window(winHandle);
}
}
WebElement ele = driver.findElement(By.xpath("//*[@id='passd']"));
ele.sendKeys("THE PASSWORD");
ele.sendKeys(Keys.ENTER);