user422506
user422506

Reputation: 31

How to access td tag and innertext of a web page

I have a web page in java script on that i have elements which is a innertext of element that is in td tag.

Upvotes: 1

Views: 1425

Answers (1)

Vishalgiri
Vishalgiri

Reputation: 484

I don't know if I have understood the question properly, but here is some info which might be helpful.

To select TD (Table Cell):

$browser.cell(:id, "leftcolumn")

And to get the innerText of any element or page:

$browser.cell(:id, "leftcolumn").text

So if you want to find the inner text of a cell, here is a example:

require 'rubygems'
require 'watir'

$browser = Watir::IE.start("http://www.w3schools.com/")
$browser.speed = :fast
$browser.bring_to_front
$browser.maximize

left_col = $browser.cell(:id, "leftcolumn").text
puts left_col.text
puts left_col.html

Please notice .html will return the inner html of the element.

Hope this helps.

Regards,
Vishalgiri Goswami

Upvotes: 1

Related Questions