There is a div on a page that is not visible but has some value I want to capture. Calling text on it returns me an empty string.
How do I get the value displayed without having to deal with the raw html? Can I force .text to return me the actual value regardless of the visiblity of the text in the browser?
irb(main):1341:0> d.first.visible?
=> false
irb(main):1344:0> d.first.html
=> "<div class=\"day\">7</div>"
irb(main):1345:0> d.first.text
=> ""
PS: There are many many divs (the page is caching response and display them accordingly). I considered changing all the display:none in the page or clicking to make them visible but I'd prefer to avoid this if possible. If not possible a solution with changing all the display none would be the preferred work around.
PPS: Damned, I tried to overload the visible? method in the Watir::Element class to always return true, but that didn't do the trick.
irb(main):1502:0> d.first.visible?
=> true
irb(main):1504:0> d.first.text
=> ""
value = Nokogiri::HTML("<div class=\"day\">7</div>").text # => "7"
– Stalinist