Dashboard > Watir > ... > Simple > Text Fields
Watir Log In View a printable version of the current page.
Text Fields
Added by Zeljko, last edited by Alan Baird on Jun 21, 2008  (view change)
Labels: 
(None)

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
Go to contents, previous, next page.

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