Using selenium, can I get the text of an invisible element?

Using selenium, can I get the text of an invisible element? I tried to do it using driver.getElement().getText() but I am getting an empty string.

<p id="versionInfo" style="display: none;">
    4.7.2<br/>
    20130714-1512
</p>
</footer></body>

Answers


Try javascript executor.I haven't tried it before though i was able perform click operations over invisible elements.

 JavascriptExecutor executor = (JavascriptExecutor)driver;
 String text= executor.executeScript("document.getElementById('versionInfo').innerHTML");

Javascript is not necessary, obtain the value through the textContext attribute.

var text = driver.FindElement(By.Id("demo-div")).GetAttribute("textContent")

http://yizeng.me/2014/04/08/get-text-from-hidden-elements-using-selenium-webdriver/#c-sharp


Need Your Help

How do I securely use Google API Keys

html google-maps google-maps-api-3 api-key

So I am using the Google Maps API on my first project that I am doing... So yes I am new and I am sorry if this is basic or obvious but I haven't been able to find a clear answer or direction. Belo...

is there a way in Angularjs to define constants with other constants?

angularjs angularjs-module

I'm trying to define constants with other constants, but it seems that it can't be done, because the initial constant isn't ready when the required constant depending require it. I want to be sure if