1

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.

  • 1
    I gave a general answer because it is unclear what kind of pop-up you have. If you ask a more specific question that includes your code, the page HTML and a screenshot we could help you find the element and get its content. But maybe my answer will help you get started anyways. – Niels van Reijmersdal Apr 30 at 8:22
1

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");

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.