How to handle authentication popup with Selenium WebDriver using Java

0
0

I’m trying to handle authentication popup using the code below:

FirefoxProfile profile = new FirefoxProfile();
profile
.setPreference("network.http.phishy-userpass-length", 255);
profile
.setPreference("network.automatic-ntlm-auth.trusted-uris", "x.x.x.x");
driver
= new FirefoxDriver(profile);
baseUrl
="http://" + login + ":" + password + "@" + url;
driver
.get(baseUrl + "/");

When I execute the test, the page shows the authentication popup and still loading for a until I click cancel button. A that moment, I can access to the next page ,this mean that the authentication success but still always show the authentication popup

  • You must to post comments
0
0

The Alert Method, authenticateUsing() lets you skip the Http Basic Authentication box.

WebDriverWait wait = new WebDriverWait(driver, 10);      
Alert alert = wait.until(ExpectedConditions.alertIsPresent());
alert
.authenticateUsing(new UserAndPassword(username, password));

As of Selenium 3.4 it is still in beta

Right now implementation is only done for InternetExplorerDriver

  • You must to post comments
Showing 1 result
Your Answer
Post as a guest by filling out the fields below or if you already have an account.
Name*
E-mail*
Website