I am trying to access a website, However to access the website first I need to enter username and password, After that full website will get open. When I try to send username and password through "alert.sendkeys", it gives error "No alert open". Please note website will only open when you have put the username and password first and then click on "Sign In" for authorization.My browser is chrome, version:64 and chrome driver version is :2.38. Here is my code:
public static void launchWebsite(String URL) {
driver.get(URL);
try {
WebDriverWait wait = new WebDriverWait(driver, 2);
wait.until(ExpectedConditions.alertIsPresent());
Alert alert = driver.switchTo().alert();
System.out.println(alert.getText());
alert.sendKeys("website");
alert.sendKeys("grren");
} catch (Exception e) {
System.out.println("No alertis present");
//exception handling
}
}