Friday, April 9, 2010

Watir: How to identify Radio Buttons?

Watir sets or clears radio list items by looking at the attributes available in the HTML tag. Common attributes are id and name. For complete list see HTML Elements Supported by Watir.
What you see in the web browser:
Click Me:
This is the tag in the HTML source:
"radio" name="clickme" id="one">

id Attribute

Watir code to set a radio list item using the and id attribute:
ie.radio(:id, "one").set
Watir code to clear a radio list item using the id attribute:
ie.radio(:id, "one").clear

name Attribute

Watir code to set a radio list item using the name attribute:
ie.radio(:name, "clickme").set
Watir code to clear a radio list item using the name attribute:
ie.radio(:name, "clickme").clear

No comments:

Post a Comment