Disable a pop up rendered in FF and not with IE

  • 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??


  • If you're referring to an alert:


    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.

Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2