Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in DevOps and Agile by (19.7k points)

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 an until I click the cancel button. That moment, I can access to the next page, this means that the authentication success but still always show the authentication popup

1 Answer

0 votes
by (62.9k points)

Handling Authentication/Login Popup Window using Selenium WebDriver

With the help of Alerts in Selenium, we can handle authentication pop up, below is the Selenium-WebDriver Java Code for entering Username & Password: 

driver.switchTo().alert();

driver.findElement(By.id("userID")).sendKeys("userName");

driver.findElement(By.id("password")).sendKeys("myPassword");

driver.switchTo().alert().accept();

driver.switchTo().defaultContent();

I hope it helps!

If you are interested to learn Selenium on a much deeper level and want to become a professional in the testing domain, check out Intellipaat’s automation testing certification!

 

Browse Categories

...