Text Fields
Watir sets or clears a text field by looking at the attributes available in the <input type="text"> HTML tag. Common attributes are id and name. For complete list see Methods Supported by Element.
What you see in the web browser:
This is the tag in the HTML source:
<input type="text" id="one" name="typeinme">
 |
There is also a file upload element that looks exactly like a text_field with a "Browse" button to the right. For directions on how to interact with this control, see this page. |
id Attribute
Watir code to set the text field with the string Watir World using the id attribute:
ie.text_field(:id, "one").set("Watir World")
Watir code to clear a text field using the id attribute:
ie.text_field(:id, "one").clear
name Attribute
Watir code to set the text field with the string Watir World using the name attribute:
ie.text_field(:name, "typeinme").set("Watir World")
Watir code to clear a text field using the name attribute:
ie.text_field(:name, "typeinme").clear