Dismiss Authentication Prompt in FireFox
I have tried with your inputs, Alert can be dismissed only after getting the alert text. Please try this working code
driver.get("http://www.httpwatch.com/httpgallery/authentication/#showExample10"); // open URL driver.findElement(By.id("displayImage")).click(); Thread.sleep(2000); driver.switchTo().alert(); Alert promptAlert = driver.switchTo().alert(); String alertText = promptAlert .getText(); System.out.println("Alert text is " + alertText); promptAlert.dismiss();