I'm trying to get to a table cell that has nothing identifable about it, it's position from the beginning of the page will change, but it's relative position from a table header stays the same. I'm using FireBug to construct my XPath, but whenever I try to make things relative it gives me object not found..
To see an example, go to http://www.earnings.com/company.asp?client=cb&ticker=s scroll down to where you see text "Earnings Releases", from there go down to the next table, 2nd row and get me the the value of the 7th column. @@ie = Watir::IE.start("http://www.earnings.com/company.asp? client=cb&ticker=s") page_html = Nokogiri::HTML.parse(@@ie.html) #puts page_html.xpath("html/body/table/tbody/tr/td/table[7]/tbody/ tr[3]/td[2]/table[4]/tbody/tr[2]/td/b").inner_text #1)Absolute path to "Earnings releases"; works OK #puts page_html.xpath("//*[contains(text(),'Earnings Releases')]").inner_text #2)Relative path to "Earnings releases"; works OK #puts page_html.xpath("html/body/table/tbody/tr/td/table[7]/tbody/ tr[3]/td[2]/table[5]/tbody/tr[2]/td[7]/nobr").inner_text #3)Absolute path to the actual date value "28-Apr-11 7:00 AM"; works OK #puts page_html.xpath("//*[contains(text(),'Earnings Releases')]/ table[1]/tbody/tr[2]/td[7]/nobr").inner_text #4)Relative path to the actual date value "28-Apr-11 7:00 AM"; DOES NOT WORK... -- Before posting, please read http://watir.com/support. In short: search before you ask, be nice. [email protected] http://groups.google.com/group/watir-general [email protected]
