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

Buttons

In web applications, we generally submit information we have entered or selected in the web page by clicking links, buttons and images, or by hitting Enter/Return on our keyboard.

Watir clicks buttons on a web page by looking at the attributes available in the <button>, <input type="button">, <input type="image">, <input type="reset">, and <input type="submit"> HTML tags. Common attributes are id, name and value. For complete list see Methods Supported by Element.

HTML Buttons

What you see in the web browser:

This is the tag in the HTML source:

<input type="button" id="one" name="clickme" value="Click Me">

id Attribute

This is the Watir code you need to click a button using the id attribute:

ie.button(:id, "one").click

name Attribute

This is the Watir code you need to click a button using the name attribute:

ie.button(:name, "clickme").click

value Attribute

This is the Watir code you need to click a button using the value attribute:

ie.button(:value, "Click Me").click

Image Buttons

<input type="image"> tag looks like an image, but acts like a button. Like HTML buttons it can be accessed by id, name and value attributes. Image buttons can also be accessed by their src attribute.

src Attribute

What you see in the web browser:

This is the tag in the HTML source:

<input type="image" src="images/doit.gif">

This is the Watir code you need to click a button with an image using the src attribute as a regular expression:

ie.button(:src, /doit/).click

In this case we're looking for a button with doit as part of the src attribute.

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