I need to open a site that contain authentication alert. To handle that alert I tried following code but no success:
try {
WebDriverWait wait = new WebDriverWait(driver, 100);
wait.until(ExpectedConditions.alertIsPresent());
Alert alert = driver.switchTo().alert();
alert.authenticateUsing((Credentials) new UsernamePasswordCredentials("username", "pass"));
} catch (Exception e) {
System.out.println("Alert not found");
}
Exception occur is:
Expected condition failed: waiting for alert to be present (tried for 100 second(s) with 500 MILLISECONDS interval)