TestProject Forum
Powered by leading experts in the test automation community

Retrieve text from a hidden element using selenium

WebElement.getText() does not return anything since the element in question has “visibility: hidden” style.

Is there any way around this ?

You can use the JavaScriptExecutor to retrieve the text, in this case it would be the innerHTML.

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