RE: Handle HTTP Authentication – Authentication required dialog
I’m using Selenium with the Firefox Webdriver to test different events on my Website.
One event leads to a HTTP authentication dialog.
Is there a way to set selenium to always press cancel or to reach a timeout so I don’t hang around and get back the control of the driver?
You can handle it using the Alert interface.
Code would look something like this
WebDriver driver = <Your code to initialize> WebDriverWait wait = new WebDriverWait(driver, 10); Alert alert = wait.until(ExpectedConditions.alertIsPresent()); alert.authenticateUsing(new UserAndPassword("username", "password");
You can get more details about the Alert interface here
Do let us know if it works out for you.