How? | HTML Example | Watir Example | Comment |
---|---|---|---|
:action | ie.form(:action, /page/).click | Used only for form element, specifies the URL where the form is to be submitted. | |
:after? | one two one | ie.link(:after?, ie.link(:text, "two")).click | Finds element after some other element. |
:alt | ie.image(:alt, "Continue").click | Used to find an element that has an alt attribute (img and input). | |
:class | ie.link(:class, "header").click | Used for an element that has a class attribute. | |
:for | ie.label(:for, "header").click | Used only for label element. | |
:href | ie.link(:href, /page/).click | Used to identify a link by it's href attribute. | |
:html | add a term | ie.link(:html, /id=227/).click | Used to identify a link by it's HTML. |
:id | ie.link(:id, "header").click | Used to find an element that has an id attribute. Since each id should be unique, according to the XHTML specification, this is recommended as the most reliable method to find an object. | |
:index | ie.button(:index, 1).click | Used to find the nth element of the specified type on a page. Current versions of Watir use 1-based indexing (starts counting at 1), but future versions will use 0-based indexing (starts counting at 0). | |
:method | ie.form(:method, "get").click | Used only for form, the method attribute of a form is either get or post. | |
:name | ie.link(:name, "header").click | Used to find an element that has a name attribute. This is useful for older versions of HTML, but name is deprecated in XHTML. | |
:src | ie.image(:src, /photo/).click | Used to identify an image by it's URL. | |
:text | click me | ie.link(:text, "click me").click | Used for link, span, div and other elements that contain text. |
:title | ie.link(:title, "header").click | Used for an element that has a title attribute. | |
:url | ie.link(:url, /page/).click | :url is synonym for :href. | |
:value | ie.text_field(:value, "text").click | Used to find a text field with a given default value, or a button with a given value. | |
:xpath | ie.link(:xpath,"//a[@href='page.htm']").click | Finds the item using XPath query. | |
Multiple Attributes | click me click me | ie.link(:text => "click me", :index => 2).click | You can combine more ways of finding elements. This example will click the second link with text click me. |
This will help you for Automation Software Testing with Watir Tool(Ruby)
Friday, April 9, 2010
Ways Available To Identify HTML Element: How to identify HTML Elemnts?
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment