-1

When I open my firefox through webdriver, then it gives a authentication pop up message as shown in image. Sometimes it comes more than one time after providing the credentials. My requirement is to identify this popup. Locate and provide values in Username and password boxes. and script for the remaining logic. (Image is stored here: http://imgur.com/a54tAbo) below is the logic which I applied but not working. Can you please help me to handle this situation.

String openWindowHandle = driver.getWindowHandle();
Set<String> AllWindowHandles = driver.getWindowHandles();
   for (String currentWindowHandle : allWindowHandles) {
      if (!currentWindowHandle.equals(openWindowHandle)){
          driver.switchTo().window(currentWindowHandle); /* Enter username and password and click on OK. */
      }
   } 
Jamie Rees
  • 7,973
  • 2
  • 45
  • 83
Durgesh
  • 585
  • 4
  • 12
  • 33
  • possible duplicate of [How to handle authentication popup with Selenium Webdriver](http://stackoverflow.com/questions/24304752/how-to-handle-authentication-popup-with-selenium-webdriver) – Helping Hands Jan 23 '15 at 12:23

1 Answers1

-2

You can do this:

WebDriverWait wdWait = new WebDriverWait(webdriver, 10);
Alert alert = wdWait.until(ExpectedConditions.alertIsPresent());
alert.authenticateUsing(new UserAndPassword("username", "password"));
Jamie Rees
  • 7,973
  • 2
  • 45
  • 83