TestProject Forum
Powered by leading experts in the test automation community

Retrieve text of <span> element that is not displayed

I’m testing a webpage that has a with innerHTML value of a number I need
e.g.

<span class="percent" style="display:none">50</span>

nightwatch’s getText() returns only the “displayable” text. in my case its null.
What is the right way to get the value ?

Try using getAttribute:

browser.getAttribute('.percent', 'innerHTML', function(r) { 
    alert(r.value);
})