Dashboard > Watir > ... > Tutorial > Finding Page Elements
Watir Log In View a printable version of the current page.
Finding Page Elements
Added by Zeljko, last edited by Zeljko on Mar 14, 2008  (view change) show comment
Labels: 
(None)

Finding Page Elements

Not all HTML tags will look the same. If you have difficulty getting Watir to interact with an object on your web page, try the Watir method with different attributes. The tag may come with one attribute, or it may come with several. If you still have trouble, see if the developers will add a id attribute to the offending tag.

Choosing Attributes

If you are having difficulty getting Watir to interact with an object, try using the method with different tag attributes. Tag declarations in HTML are varied. Some developers use tools that generate HTML, and there are many variations on tag attributes. Watir is very flexible and offers several variations on each method. There are also attributes that are part of the DOM within Internet Explorer. Anything the DOM can see, you can access using Ruby. If you have exhausted the attributes on a tag and Watir still won't interact with it, send an email to the Watir General Google Group. Please read Support before posting. The Watir development team will help out, and if needed, add support for that situation within Watir.

Accessing Tags Using Alternate Methods

In some situations, you may not know what the tag attributes of an HTML object are. They may be missing, or the tag attributes might be dynamically generated. Some web architectures dynamically generate tags, and the attributes might change each time you run a test. To work around this, try the following:

Go to contents, previous, next page.
CSS (Watir)
Index (Watir)
IRB (Watir)
Multiple Attributes (Watir)
Regular Expressions (Watir)
XPath (Watir)

Site running on a free Atlassian Confluence Community License granted to OpenQA. Evaluate Confluence today.
Powered by Atlassian Confluence, the Enterprise Wiki. (Version: 2.5.6 Build:#812 Aug 06, 2007) - Bug/feature request - Contact Administrators