Reputation: 251
Consider:
I need to find a way how I could get the text from the popup using Selenium/core Java, so that I can compare the text with expected data.
Is there a way I could extract the text from the popup?
A screenshot is attached.
Upvotes: 0
Views: 1963
Reputation: 106
If you inspect the element which has the focus. This is possible with all common browsers via development tools or use the SeleniumIDE Plugin for Firefox to get information about that page and build locators. Often framework are used (like bootstrap) to ensure a consistent layout so a CSS-locator might look like:
var popupBody = driver.FindElement(By.CssSelector("div.modal-dialog div.content div.body")
Note that in this case Bootstrap would not the call the class 'popup' but 'modal-dialog'. The locator might furthermore vary depending on the inner structure. As mentioned inspect the element (or share the HTML code so we can suggest concrete locator).
By this you get a normal WebElement ala Selenium where you can get the Text
// use the element
.. popupBody.Text ..
Upvotes: 1