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?

johnsmithv2 Default Asked on February 25, 2015 in Selenium WebDriver.
Add Comment
4 Answers

Hi John,

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

https://selenium.googlecode.com/git/docs/api/java/org/openqa/selenium/Alert.html

Do let us know if it works out for you.

Thanks
Virender

Professor Answered on February 26, 2015.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.