0

The website that I am trying to automate has a authentication popup that appears when someone visits it. I tried the following code but Chrome immediately throws no alert present exception on the switchTo() line.

Firefox does not seem to be working. I am currently using Selenium 3.6.0 with the latest binaries of these browsers. Can someone please help me out?

driver = new FirefoxDriver();
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
driver.get("https://staging.brightsociety.com/");
WebDriverWait wait = new WebDriverWait(driver, 10);
wait.until(ExpectedConditions.alertIsPresent());
Alert alert = driver.switchTo().alert();
alert.authenticateUsing(new UserAndPassword(username, password));
driver.switchTo().defaultContent();

http://staging.brightsociety.com

authentication required

0buz
  • 3,443
  • 2
  • 8
  • 29
Varun Bali
  • 133
  • 1
  • 2
  • 17
  • Possible duplicate of [Selenium - Other way to basic authenticate than via url](https://stackoverflow.com/questions/45345882/selenium-other-way-to-basic-authenticate-than-via-url) – undetected Selenium Nov 08 '17 at 09:19

2 Answers2

1

Selenium do not handle it by switchto command because this is something that is browser specific instead of website.

Solution 1:

driver.get("http://username:password@url.com");

But problem with this method is that as you traverse to multiple pages the popup will appear again and again which is again difficult to handle.

Solution 2: (Recommended)

AutoIt script, Download AutoIt here And Find the Script for Authentication PopUp here

Rabia Asif
  • 298
  • 3
  • 14
0

Do you need check it or pass it? If you need to pass, put login and password in URL.

http://username:password@your-web-site.com
Skytrace
  • 58
  • 4