1

when testing with Selenium Webdriver, I'm getting an advertising pop up window with Firefox and not with IE. Actually this pop up is preventing me from doing many other tasks. Is there a way to disable this kind of pop up when creating the Firefox driver??

Thanks

1
  • Can you elaborate what the pop up displays? And does selenium make it appear or is it because of some other reason? Sep 30 '14 at 2:31
1

If you're referring to an alert:

driver.switchTo().alert().dismiss();

That will dismiss a JavaScript alert.

If you're talking about a pop up that is a part of the application's functionality and it's not working in IE, that's a bug if you're supposed to support IE and that's up to the developer to fix.

In any case, a pop up is usually dealt with using window handles.

Here's an example:

    String parentHandle = driver.getWindowHandle(); // get the current window handle
driver.findElement(By.xpath("//*[@id='someXpath']")).click(); // click some link that opens a new window

for (String winHandle : driver.getWindowHandles()) {
    driver.switchTo().window(winHandle); // switch focus of WebDriver to the next found window handle (that's your newly opened window)
}

//code to do something on new window

driver.close(); // close newly opened window when done with it
driver.switchTo().window(parentHandle); // switch back to the original window

This example was provided in the following thread: https://stackoverflow.com/questions/19112209/how-to-handle-the-new-window-in-selenium-webdriver

You're using C# and my examples are in JAVA, but you'll at least know where to begin your search now.

1
  • You might also have pop-up blocker enabled in IE. I'd check that too. There are several ways to handle it. Here's an example: ieCapabilities.setCapability("disable-popup-blocking", true);
    – user8884
    Jan 13 '15 at 23:25
1

Handling pop-up is a better approach then disabling them, but in case of advertisement pop-up it is fine to disable them.

To completely disable the pop-up, go to Tools > Options > Content and check the option for Block pop-up windows

0

If the pop-up window is part of the web-based app, that you are testing, you need to know why is only happening on FF and not on IE.

There is a definitely a way on the settings on FF to disable pop up; however, IF in the future it is require to have pop-ups on your app, you will not have a user-oriented environment. Thus, I strongly suggest to not disable pop-ups

Suggestion:

Code your script to check if you are running on FF-> then handle the pop up.

in your code add something to interact with the pop-up, like set the active browser to be the pop-up window, and then close it. This way, you will be able to continue working with everything else.

2
  • This is a bit too generic to really answer the question, which is how to disable unwanted popups when creating the Firefox driver. Coding a check for firefox and handling the popup there is more of a workaround, as is modifying the firefox settings to block popups.
    – Kate Paulk
    Oct 2 '14 at 16:46
  • The question is a bit generic as well. Handling the pop-up is much better approach then disable them.
    – AlolEX
    Oct 2 '14 at 17:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.