Testing a pop-up in Selenium



  • How to select text from pop up which is opened in the same page in Selenium.

    With WebDriver I can only check the element from the page, not from pop up.



  • Handling pop-up is somewhat hard in with Selenium, mainly because there are three types of popups.

    JavaScript Alerts

    The simplest browser dialogs are JavaScript alerts. They have a special API to access their data because they are not part of the DOM.

    driver.switchTo().alert().getText();
    

    Read more at https://www.guru99.com/alert-popup-handling-selenium.html

    Dialogs in HTML

    This is not real popup, but they make the background darker/blurred and look like a dialog. Actually, they are just an HTML div with content. Handle them like any other web-element.

    Real pop-ups

    This is a new window that opens above (or below) the current window. You first need to switch to the window before you can access its contents. You also need to switch back afterward.

    driver.switchTo().window("windowName");
    


Suggested Topics

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