How do I get the id or name of an element in watir?

Posted by karlthorwald on Stack Overflow See other posts from Stack Overflow or by karlthorwald
Published on 2010-04-27T01:07:24Z Indexed on 2010/04/27 1:13 UTC
Read the original article Hit count: 277

Filed under:

Watir can find a text on a page:

<span id="i1" name="n1>Some Text</span>

e.text.include?("Some Text")

But how can I get the name or id of the span, when I only know "Some Text"

e.text.findInPage("Some Text").parentElement.id (should be "i1")
e.text.findInPage("Some Text").parentElement.name (should be "n1");

Something like this exists in watir?

© Stack Overflow or respective owner

Related posts about watir