IE8, Ruby 1.9.3, Watir 3.0, WindowsXP
I need to capture text in a cell with id = "numberCovered".
<table cellpadding="0" cellspacing="0" class="thisThemeBodyColor"><tr style="height:22px;"><td id="numberCoveredlabel" style="cursor:default;" class="smallHeadingBlack" width="200">Number of individuals to be covered</td><td id="numberCovered" class="smallHeadingBlack" style="font-weight:bold;">1</td><input type="hidden" name="numberCovered" tooltip="" value="1" onpropertychange="variableAsTextChanged(this);"/></tr><tr><td id="numberSpouseslabel" style="cursor:default;" class="smallHeadingBlack" width="200">Number of spouses to be covered</td><td id="numberSpouses" class="smallHeadingBlack" style="font-weight:bold;">0</td><input type="hidden" name="numberSpouses" tooltip="" value="0" onpropertychange="variableAsTextChanged(this);"/></tr></table>
As already mentioned, the initial dump of the original page is sometimes nice, because you cannot find the appropriate Watir built-in method.
- Update-- The above $ browser.html spewed out empty lines, but this seems to work:
require 'nokogiri' page_html = Nokogiri::HTML.parse($browser.html) entry = page_html.css('td[id=numberCovered]')
source share