Retrieve text from a hidden element using selenium

  • 1 Replies
  • 921 Views
Retrieve text from a hidden element using selenium
« on: April 03, 2016, 19:34:06 pm »
WebElement.getText() does not return anything since the element in question has "visibility: hidden" style.

Is there any way around this ?

*

Oren

  • **
  • 59
Re: Retrieve text from a hidden element using selenium
« Reply #1 on: April 04, 2016, 19:02:57 pm »
You can use the JavaScriptExecutor to retrieve the text, in this case it would be the innerHTML.

Code
jsDriver = (JavascriptExecutor) driver;
String text = jsDriver.executeScript("return arguments[0].innerHTML", myElement);

 

Sitemap 1 2 3 4 5 6 7 8