retrieve text of <span> element that is not displayed

  • 1 Replies
  • 1262 Views
*

Karen

  • *
  • 17
retrieve text of <span> element that is not displayed
« on: May 05, 2016, 22:16:45 pm »
I'm testing a webpage that has a <span> with innerHTML value of a number I need
e.g.
Code
<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 ?

*

Ruhit

  • *
  • 22
Re: retrieve text of <span> element that is not displayed
« Reply #1 on: May 08, 2016, 17:23:28 pm »
Try using getAttribute:

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

 

Sitemap 1 2 3 4 5 6 7 8