In Chrome, clicking a certain link opens a new tab with an "Authentication Required" popup. As you can see, it has 'User name' and 'password' with 'Log In' and 'Cancel' buttons.
With Java code, how can I enter values (user name and password) in this popup? Because I can't get the locator of username and password, also the alert method is not working here.
The code I tried:
public static void switchToalert() {
driver.switchTo().alert();
// Selenium-WebDriver Java Code for entering Username & Password as // below:
driver.findElement(By.id("Username")).sendKeys("userName");
driver.findElement(By.id("Password")).sendKeys("myPassword");
driver.switchTo().alert().accept();
driver.switchTo().defaultContent();
}
Thanks Govind