Skip to content
cheezy edited this page Oct 4, 2011 · 34 revisions

Elements are the items that appear on the html page. Using page-object you can find and interact with a large number of elements. This page lists the elements, the generated methods, and info on what values you can use to find an element.

Button

You declare a Button using the following method call:

button(:your_name, :id => 'an_id')

Four methods are generated with this call. They are:

your_name             # clicks the Button
your_name_element     # returns the Button element

You can locate a Button by provide one or more of the following values:

  • :class => Watir and Selenium
  • :id => Watir and Selenium
  • :index => Watir and Selenium
  • :name => Watir and Selenium
  • :text => Watir and Selenium
  • :value => Watir and Selenium
  • :xpath => Watir and Selenium

Checkbox

You declare a Checkbox using the following method call:

checkbox(:your_name, :id => 'an_id')

Four methods are generated with this call. They are:

check_your_name          # checks the Checkbox
uncheck_your_name        # unchecks the Checkbox
your_name_checked?       # returns if the Checkbox is checked
your_name_element        # returns the Checkbox element

You can locate a Checkbox by provide one or more of the following values:

  • :class => Watir and Selenium
  • :id => Watir and Selenium
  • :index => Watir and Selenium
  • :name => Watir and Selenium
  • :xpath => Watir and Selenium

Div

You declare a Div using the following method call:

div(:your_name, :id => 'an_id')

Four methods are generated with this call. They are:

your_name             # returns the text within the Div
your_name_element     # returns the Div element

You can locate a Div by provide one or more of the following values:

  • :class => Watir and Selenium
  • :id => Watir and Selenium
  • :index => Watir and Selenium
  • :name => Watir and Selenium
  • :text => Watir and Selenium
  • :xpath => Watir and Selenium

HiddenField

You declare a HiddenField using the following method call:

hidden_field(:your_name, :id => 'an_id')

Two methods are generated with this call. They are:

your_name          # returns the value in the HiddenField
your_name_element  # returns the HiddenField element

You can locate a HiddenField by provide one or more of the following values:

  • :class => Watir and Selenium
  • :css => Watir and Selenium
  • :id => Watir and Selenium
  • :index => Watir and Selenium
  • :name => Watir and Selenium
  • :text => Watir and Selenium
  • :xpath => Watir and Selenium

Link

You declare a Link using the following method call:

link(:your_name, :id => 'an_id')

Two methods are generated with this call. They are:

your_name          # clicks the Link
your_name_element  # returns the Link element

You can locate a Link by provide one or more of the following values:

  • :class => Watir and Selenium
  • :href => Watir and Selenium
  • :id => Watir and Selenium
  • :index => Watir and Selenium
  • :link => Watir and Selenium
  • :link_text => Watir and Selenium
  • :name => Watir and Selenium
  • :text => Watir and Selenium
  • :xpath => Watir and Selenium

RadioButton

You declare a RadioButton using the following method call:

radio_button(:your_name, :id => 'an_id')

Four methods are generated with this call. They are:

select_your_name          # selects the RadioButton
clear_your_name           # clears the RadioButton
your_name_selected?       # returns if the RadioButton is selected
your_name_element         # returns the RadioButton element

You can locate a RadioButton by provide one or more of the following values:

  • :class => Watir and Selenium
  • :id => Watir and Selenium
  • :index => Watir and Selenium
  • :name => Watir and Selenium
  • :xpath => Watir and Selenium

SelectList (Dropdown)

You declare a SelectList using the following method call:

select_list(:your_name, :id => 'an_id')

Three methods are generated with this call. They are:

your_name          # returns the value selected in the SelectList
your_name=         # sets the selected value in the SelectList
your_name_element  # returns the SelectList element

You can locate a SelectList by provide one or more of the following values:

  • :class => Watir and Selenium
  • :id => Watir and Selenium
  • :index => Watir and Selenium
  • :name => Watir and Selenium
  • :text => Watir only
  • :value => Watir only
  • :xpath => Watir and Selenium

Span

You declare a Span using the following method call:

span(:your_name, :id => 'an_id')

Four methods are generated with this call. They are:

your_name             # returns the text within the Span
your_name_element     # returns the Span element

You can locate a Span by provide one or more of the following values:

  • :class => Watir and Selenium
  • :id => Watir and Selenium
  • :index => Watir and Selenium
  • :name => Watir and Selenium
  • :xpath => Watir and Selenium

TextArea

You declare a TextArea using the following method call:

text_area(:your_name, :id => 'an_id')

Three methods are generated with this call. They are:

your_name          # returns the value in the TextArea
your_name=         # sets the value in the TextArea
your_name_element  # returns the TextArea element

You can locate a TextArea by provide one or more of the following values:

  • :class => Watir and Selenium
  • :css => Watir and Selenium
  • :id => Watir and Selenium
  • :index => Watir and Selenium
  • :name => Watir and Selenium
  • :xpath => Watir and Selenium

TextField

You declare a TextField using the following method call:

text_field(:your_name, :id => 'an_id')

Three methods are generated with this call. They are:

your_name          # returns the value in the TextField
your_name=         # sets the value in the TextField
your_name_element  # returns the TextField element

You can locate a TextField by provide one or more of the following values:

  • :class => Watir and Selenium
  • :css => Watir and Selenium
  • :id => Watir and Selenium
  • :index => Watir and Selenium
  • :name => Watir and Selenium
  • :text => Watir only
  • :value => Watir only
  • :xpath => Watir and Selenium