lib/page-object/accessors.rb in page-object-2.0.0 vs lib/page-object/accessors.rb in page-object-2.1
- old
+ new
@@ -5,13 +5,10 @@
#
# Contains the class level methods that are inserted into your page objects
# when you include the PageObject module. These methods will generate another
# set of methods that provide access to the elements on the web pages.
#
- # @see PageObject::WatirPageObject for the watir implementation of the platform delegate
- # @see PageObject::SeleniumPageObject for the selenium implementation of the platform delegate
- #
module Accessors
#
# Set some values that can be used within the class. This is
# typically used to provide values that help build dynamic urls in
@@ -143,14 +140,14 @@
# in_frame(:id => 'frame_id') do |frame|
# text_field(:first_name, :id => 'fname', :frame => frame)
# end
#
# @param [Hash] identifier how we find the frame. The valid keys are:
- # * :id => Watir and Selenium
- # * :index => Watir and Selenium
- # * :name => Watir and Selenium
- # * :regexp => Watir only
+ # * :id
+ # * :index
+ # * :name
+ # * :regexp
# @param frame passed from a previous call to in_frame. Used to nest calls
# @param block that contains the calls to elements that exist inside the frame.
#
def in_frame(identifier, frame=nil, &block)
frame = frame.nil? ? [] : frame.dup
@@ -167,14 +164,14 @@
# in_iframe(:id => 'frame_id') do |frame|
# text_field(:first_name, :id => 'fname', :frame => frame)
# end
#
# @param [Hash] identifier how we find the frame. The valid keys are:
- # * :id => Watir and Selenium
- # * :index => Watir and Selenium
- # * :name => Watir and Selenium
- # * :regexp => Watir only
+ # * :id
+ # * :index
+ # * :name
+ # * :regexp
# @param frame passed from a previous call to in_iframe. Used to nest calls
# @param block that contains the calls to elements that exist inside the iframe.
#
def in_iframe(identifier, frame=nil, &block)
frame = frame.nil? ? [] : frame.dup
@@ -191,22 +188,11 @@
# text_field(:first_name, :id => "first_name")
# # will generate 'first_name', 'first_name=', 'first_name_element',
# # 'first_name?' methods
#
# @param [String] the name used for the generated methods
- # @param [Hash] identifier how we find a text field. You can use a multiple parameters
- # by combining of any of the following except xpath. The valid keys are:
- # * :class => Watir and Selenium
- # * :css => Watir and Selenium
- # * :id => Watir and Selenium
- # * :index => Watir and Selenium
- # * :label => Watir and Selenium
- # * :name => Watir and Selenium
- # * :text => Watir and Selenium
- # * :title => Watir and Selenium
- # * :value => Watir only
- # * :xpath => Watir and Selenium
+ # @param [Hash] identifier how we find a text field.
# @param optional block to be invoked when element method is called
#
def text_field(name, identifier={:index => 0}, &block)
standard_methods(name, identifier, 'text_field_for', &block)
define_method(name) do
@@ -227,20 +213,11 @@
# @example
# hidden_field(:user_id, :id => "user_identity")
# # will generate 'user_id', 'user_id_element' and 'user_id?' methods
#
# @param [String] the name used for the generated methods
- # @param [Hash] identifier how we find a hidden field. You can use a multiple parameters
- # by combining of any of the following except xpath. The valid keys are:
- # * :class => Watir and Selenium
- # * :css => 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
+ # @param [Hash] identifier how we find a hidden field.
# @param optional block to be invoked when element method is called
#
def hidden_field(name, identifier={:index => 0}, &block)
standard_methods(name, identifier, 'hidden_field_for', &block)
define_method(name) do
@@ -259,19 +236,11 @@
# text_area(:address, :id => "address")
# # will generate 'address', 'address=', 'address_element',
# # 'address?' methods
#
# @param [String] the name used for the generated methods
- # @param [Hash] identifier how we find a text area. You can use a multiple parameters
- # by combining of any of the following except xpath. The valid keys are:
- # * :class => Watir and Selenium
- # * :css => Watir and Selenium
- # * :id => Watir and Selenium
- # * :index => Watir and Selenium
- # * :name => Watir and Selenium
- # * :xpath => Watir and Selenium
- # * :label => Watir and Selenium
+ # @param [Hash] identifier how we find a text area.
# @param optional block to be invoked when element method is called
#
def text_area(name, identifier={:index => 0}, &block)
standard_methods(name, identifier, 'text_area_for', &block)
define_method(name) do
@@ -295,21 +264,11 @@
# @example
# select_list(:state, :id => "state")
# # will generate 'state', 'state=', 'state_element', 'state?', "state_options" methods
#
# @param [Symbol] the name used for the generated methods
- # @param [Hash] identifier how we find a select list. You can use a multiple parameters
- # by combining of any of the following except xpath. The valid keys are:
- # * :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
- # * :label => Watir and Selenium
+ # @param [Hash] identifier how we find a select list.
# @param optional block to be invoked when element method is called
#
def select_list(name, identifier={:index => 0}, &block)
standard_methods(name, identifier, 'select_list_for', &block)
define_method(name) do
@@ -335,23 +294,11 @@
# @example
# link(:add_to_cart, :text => "Add to Cart")
# # will generate 'add_to_cart', 'add_to_cart_element', and 'add_to_cart?' methods
#
# @param [Symbol] the name used for the generated methods
- # @param [Hash] identifier how we find a link. You can use a multiple parameters
- # by combining of any of the following except xpath. The valid keys are:
- # * :class => Watir and Selenium
- # * :css => 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
- # * :title => Watir and Selenium
- # * :xpath => Watir and Selenium
+ # @param [Hash] identifier how we find a link.
# @param optional block to be invoked when element method is called
#
def link(name, identifier={:index => 0}, &block)
standard_methods(name, identifier, 'link_for', &block)
define_method(name) do
@@ -371,20 +318,11 @@
# checkbox(:active, :name => "is_active")
# # will generate 'check_active', 'uncheck_active', 'active_checked?',
# # 'active_element', and 'active?' methods
#
# @param [Symbol] the name used for the generated methods
- # @param [Hash] identifier how we find a checkbox. You can use a multiple parameters
- # by combining of any of the following except xpath. The valid keys are:
- # * :class => Watir and Selenium
- # * :css => Watir and Selenium
- # * :id => Watir and Selenium
- # * :index => Watir and Selenium
- # * :name => Watir and Selenium
- # * :value => Watir and Selenium
- # * :xpath => Watir and Selenium
- # * :label => Watir and Selenium
+ # @param [Hash] identifier how we find a checkbox.
# @param optional block to be invoked when element method is called
#
def checkbox(name, identifier={:index => 0}, &block)
standard_methods(name, identifier, 'checkbox_for', &block)
define_method("check_#{name}") do
@@ -411,20 +349,11 @@
# radio_button(:north, :id => "north")
# # will generate 'select_north', 'north_selected?',
# # 'north_element', and 'north?' methods
#
# @param [Symbol] the name used for the generated methods
- # @param [Hash] identifier how we find a radio button. You can use a multiple parameters
- # by combining of any of the following except xpath. The valid keys are:
- # * :class => Watir and Selenium
- # * :css => Watir and Selenium
- # * :id => Watir and Selenium
- # * :index => Watir and Selenium
- # * :name => Watir and Selenium
- # * :value => Watir and Selenium
- # * :xpath => Watir and Selenium
- # * :label => Watir and Selenium
+ # @param [Hash] identifier how we find a radio button.
# @param optional block to be invoked when element method is called
#
def radio_button(name, identifier={:index => 0}, &block)
standard_methods(name, identifier, 'radio_button_for', &block)
define_method("select_#{name}") do
@@ -454,11 +383,11 @@
# 'color_elements', and 'color?' methods
#
# @param [Symbol] the name used for the generated methods
# @param [Hash] shared identifier for the radio button group. Typically, a 'name' attribute.
# The valid keys are:
- # * :name => Watir and Selenium
+ # * :name
#
def radio_button_group(name, identifier)
define_method("select_#{name}") do |value|
platform.radio_buttons_for(identifier.clone).each do |radio_elem|
if radio_elem.value == value
@@ -495,22 +424,11 @@
# @example
# button(:purchase, :id => 'purchase')
# # will generate 'purchase', 'purchase_element', and 'purchase?' methods
#
# @param [Symbol] the name used for the generated methods
- # @param [Hash] identifier how we find a button. You can use a multiple parameters
- # by combining of any of the following except xpath. The valid keys are:
- # * :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 and Selenium
- # * :xpath => Watir and Selenium
- # * :src => Watir and Selenium (input type=image only)
- # * :alt => Watir and Selenium (input type=image only)
+ # @param [Hash] identifier how we find a button.
# @param optional block to be invoked when element method is called
#
def button(name, identifier={:index => 0}, &block)
standard_methods(name, identifier, 'button_for', &block)
define_method(name) do
@@ -526,20 +444,11 @@
# @example
# div(:message, :id => 'message')
# # will generate 'message', 'message_element', and 'message?' methods
#
# @param [Symbol] the name used for the generated methods
- # @param [Hash] identifier how we find a div. You can use a multiple parameters
- # by combining of any of the following except xpath. The valid keys are:
- # * :class => Watir and Selenium
- # * :css => Watir and Selenium
- # * :id => Watir and Selenium
- # * :index => Watir and Selenium
- # * :name => Watir and Selenium
- # * :text => Watir and Selenium
- # * :title => Watir and Selenium
- # * :xpath => Watir and Selenium
+ # @param [Hash] identifier how we find a div.
# @param optional block to be invoked when element method is called
#
def div(name, identifier={:index => 0}, &block)
standard_methods(name, identifier, 'div_for', &block)
define_method(name) do
@@ -555,20 +464,11 @@
# @example
# span(:alert, :id => 'alert')
# # will generate 'alert', 'alert_element', and 'alert?' methods
#
# @param [Symbol] the name used for the generated methods
- # @param [Hash] identifier how we find a span. You can use a multiple parameters
- # by combining of any of the following except xpath. The valid keys are:
- # * :class => Watir and Selenium
- # * :css => Watir and Selenium
- # * :id => Watir and Selenium
- # * :index => Watir and Selenium
- # * :name => Watir and Selenium
- # * :text => Watir and Selenium
- # * :title => Watir and Selenium
- # * :xpath => Watir and Selenium
+ # @param [Hash] identifier how we find a span.
# @param optional block to be invoked when element method is called
#
def span(name, identifier={:index => 0}, &block)
standard_methods(name, identifier, 'span_for', &block)
define_method(name) do
@@ -578,26 +478,18 @@
end
#
# adds three methods - one to return the text for the table, one
# to retrieve the table element, and another to
- # check the table's existence. The existence method does not work
- # on Selenium so it should not be called.
+ # check the table's existence.
#
# @example
# table(:cart, :id => 'shopping_cart')
# # will generate a 'cart', 'cart_element' and 'cart?' method
#
# @param [Symbol] the name used for the generated methods
- # @param [Hash] identifier how we find a table. You can use a multiple parameters
- # by combining of any of the following except xpath. The valid keys are:
- # * :class => Watir and Selenium
- # * :css => Watir and Selenium
- # * :id => Watir and Selenium
- # * :index => Watir and Selenium
- # * :name => Watir and Selenium
- # * :xpath => Watir and Selenium
+ # @param [Hash] identifier how we find a table.
# @param optional block to be invoked when element method is called
#
def table(name, identifier={:index => 0}, &block)
standard_methods(name, identifier, 'table_for', &block)
define_method(name) do
@@ -614,20 +506,11 @@
# @example
# cell(:total, :id => 'total_cell')
# # will generate 'total', 'total_element', and 'total?' methods
#
# @param [Symbol] the name used for the generated methods
- # @param [Hash] identifier how we find a cell. You can use a multiple parameters
- # by combining of any of the following except xpath. The valid keys are:
- # * :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
- # * :css => Watir and Selenium
+ # @param [Hash] identifier how we find a cell.
# @param optional block to be invoked when element method is called
#
def cell(name, identifier={:index => 0}, &block)
standard_methods(name, identifier, 'cell_for', &block)
define_method("#{name}") do
@@ -646,19 +529,11 @@
# @example
# row(:sums, :id => 'sum_row')
# # will generate 'sums', 'sums_element', and 'sums?' methods
#
# @param [Symbol] the name used for the generated methods
- # @param [Hash] identifier how we find a cell. You can use a multiple parameters
- # by combining of any of the following except xpath. The valid keys are:
- # * :class => Watir and Selenium
- # * :css => Watir and Selenium
- # * :id => Watir and Selenium
- # * :index => Watir and Selenium
- # * :text => Watir only
- # * :xpath => Watir and Selenium
- # * :css => Watir and Selenium
+ # @param [Hash] identifier how we find a cell.
# @param optional block to be invoked when element method is called
#
def row(name, identifier={:index => 0}, &block)
standard_methods(name, identifier, 'row_for', &block)
define_method("#{name}") do
@@ -675,20 +550,11 @@
# @example
# image(:logo, :id => 'logo')
# # will generate 'logo_element', 'logo_loaded?', and 'logo?' methods
#
# @param [Symbol] the name used for the generated methods
- # @param [Hash] identifier how we find an image. You can use a multiple parameters
- # by combining of any of the following except xpath. The valid keys are:
- # * :alt => Watir and Selenium
- # * :class => Watir and Selenium
- # * :css => Watir and Selenium
- # * :id => Watir and Selenium
- # * :index => Watir and Selenium
- # * :name => Watir and Selenium
- # * :src => Watir and Selenium
- # * :xpath => Watir and Selenium
+ # @param [Hash] identifier how we find an image.
# @param optional block to be invoked when element method is called
#
def image(name, identifier={:index => 0}, &block)
standard_methods(name, identifier, 'image_for', &block)
define_method("#{name}_loaded?") do
@@ -705,18 +571,11 @@
# @example
# form(:login, :id => 'login')
# # will generate 'login_element' and 'login?' methods
#
# @param [Symbol] the name used for the generated methods
- # @param [Hash] identifier how we find a form. You can use a multiple parameters
- # by combining of any of the following except xpath. The valid keys are:
- # * :action => Watir and Selenium
- # * :class => Watir and Selenium
- # * :css => Watir and Selenium
- # * :id => Watir and Selenium
- # * :index => Watir and Selenium
- # * :xpath => Watir and Selenium
+ # @param [Hash] identifier how we find a form.
# @param optional block to be invoked when element method is called
#
def form(name, identifier={:index => 0}, &block)
standard_methods(name, identifier, 'form_for', &block)
end
@@ -729,19 +588,11 @@
# @example
# list_item(:item_one, :id => 'one')
# # will generate 'item_one', 'item_one_element', and 'item_one?' methods
#
# @param [Symbol] the name used for the generated methods
- # @param [Hash] identifier how we find a list item. You can use a multiple parameters
- # by combining of any of the following except xpath. The valid keys are:
- # * :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
+ # @param [Hash] identifier how we find a list item.
# @param optional block to be invoked when element method is called
#
def list_item(name, identifier={:index => 0}, &block)
standard_methods(name, identifier, 'list_item_for', &block)
define_method(name) do
@@ -759,18 +610,11 @@
# @example
# unordered_list(:menu, :id => 'main_menu')
# # will generate 'menu', 'menu_element' and 'menu?' methods
#
# @param [Symbol] the name used for the generated methods
- # @param [Hash] identifier how we find an unordered list. You can use a multiple parameters
- # by combining of any of the following except xpath. The valid keys are:
- # * :class => Watir and Selenium
- # * :css => Watir and Selenium
- # * :id => Watir and Selenium
- # * :index => Watir and Selenium
- # * :name => Watir and Selenium
- # * :xpath => Watir and Selenium
+ # @param [Hash] identifier how we find an unordered list.
# @param optional block to be invoked when element method is called
#
def unordered_list(name, identifier={:index => 0}, &block)
standard_methods(name, identifier, 'unordered_list_for', &block)
define_method(name) do
@@ -788,18 +632,11 @@
# @example
# ordered_list(:top_five, :id => 'top')
# # will generate 'top_five', 'top_five_element' and 'top_five?' methods
#
# @param [Symbol] the name used for the generated methods
- # @param [Hash] identifier how we find an ordered list. You can use a multiple parameters
- # by combining of any of the following except xpath. The valid keys are:
- # * :class => Watir and Selenium
- # * :css => Watir and Selenium
- # * :id => Watir and Selenium
- # * :index => Watir and Selenium
- # * :name => Watir and Selenium
- # * :xpath => Watir and Selenium
+ # @param [Hash] identifier how we find an ordered list.
# @param optional block to be invoked when element method is called
#
def ordered_list(name, identifier={:index => 0}, &block)
standard_methods(name, identifier, 'ordered_list_for', &block)
define_method(name) do
@@ -817,17 +654,11 @@
# h1(:title, :id => 'title')
# # will generate 'title', 'title_element', and 'title?' methods
#
# @param [Symbol] the name used for the generated methods
# @param [Hash] identifier how we find a H1. You can use a multiple parameters
- # by combining of any of the following except xpath. The valid keys are:
- # * :class => Watir and Selenium
- # * :css => Watir and Selenium
- # * :id => Watir and Selenium
- # * :index => Watir and Selenium
- # * :name => Watir and Selenium
- # * :xpath => Watir and Selenium
+ # by combining of any of the following except xpath.
# @param optional block to be invoked when element method is called
#
def h1(name, identifier={:index => 0}, &block)
standard_methods(name, identifier,'h1_for', &block)
define_method(name) do
@@ -843,18 +674,11 @@
# @example
# h2(:title, :id => 'title')
# # will generate 'title', 'title_element', and 'title?' methods
#
# @param [Symbol] the name used for the generated methods
- # @param [Hash] identifier how we find a H2. You can use a multiple parameters
- # by combining of any of the following except xpath. The valid keys are:
- # * :class => Watir and Selenium
- # * :css => Watir and Selenium
- # * :id => Watir and Selenium
- # * :index => Watir and Selenium
- # * :name => Watir and Selenium
- # * :xpath => Watir and Selenium
+ # @param [Hash] identifier how we find a H2.
# @param optional block to be invoked when element method is called
#
def h2(name, identifier={:index => 0}, &block)
standard_methods(name, identifier, 'h2_for', &block)
define_method(name) do
@@ -870,18 +694,11 @@
# @example
# h3(:title, :id => 'title')
# # will generate 'title', 'title_element', and 'title?' methods
#
# @param [Symbol] the name used for the generated methods
- # @param [Hash] identifier how we find a H3. You can use a multiple parameters
- # by combining of any of the following except xpath. The valid keys are:
- # * :class => Watir and Selenium
- # * :css => Watir and Selenium
- # * :id => Watir and Selenium
- # * :index => Watir and Selenium
- # * :name => Watir and Selenium
- # * :xpath => Watir and Selenium
+ # @param [Hash] identifier how we find a H3.
# @param optional block to be invoked when element method is called
#
def h3(name, identifier={:index => 0}, &block)
standard_methods(name, identifier, 'h3_for', &block)
define_method(name) do
@@ -897,18 +714,11 @@
# @example
# h4(:title, :id => 'title')
# # will generate 'title', 'title_element', and 'title?' methods
#
# @param [Symbol] the name used for the generated methods
- # @param [Hash] identifier how we find a H4. You can use a multiple parameters
- # by combining of any of the following except xpath. The valid keys are:
- # * :class => Watir and Selenium
- # * :css => Watir and Selenium
- # * :id => Watir and Selenium
- # * :index => Watir and Selenium
- # * :name => Watir and Selenium
- # * :xpath => Watir and Selenium
+ # @param [Hash] identifier how we find a H4.
# @param optional block to be invoked when element method is called
#
def h4(name, identifier={:index => 0}, &block)
standard_methods(name, identifier, 'h4_for', &block)
define_method(name) do
@@ -924,18 +734,11 @@
# @example
# h5(:title, :id => 'title')
# # will generate 'title', 'title_element', and 'title?' methods
#
# @param [Symbol] the name used for the generated methods
- # @param [Hash] identifier how we find a H5. You can use a multiple parameters
- # by combining of any of the following except xpath. The valid keys are:
- # * :class => Watir and Selenium
- # * :css => Watir and Selenium
- # * :id => Watir and Selenium
- # * :index => Watir and Selenium
- # * :name => Watir and Selenium
- # * :xpath => Watir and Selenium
+ # @param [Hash] identifier how we find a H5.
# @param optional block to be invoked when element method is called
#
def h5(name, identifier={:index => 0}, &block)
standard_methods(name, identifier, 'h5_for', &block)
define_method(name) do
@@ -951,18 +754,11 @@
# @example
# h6(:title, :id => 'title')
# # will generate 'title', 'title_element', and 'title?' methods
#
# @param [Symbol] the name used for the generated methods
- # @param [Hash] identifier how we find a H6. You can use a multiple parameters
- # by combining of any of the following except xpath. The valid keys are:
- # * :class => Watir and Selenium
- # * :css => Watir and Selenium
- # * :id => Watir and Selenium
- # * :index => Watir and Selenium
- # * :name => Watir and Selenium
- # * :xpath => Watir and Selenium
+ # @param [Hash] identifier how we find a H6.
# @param optional block to be invoked when element method is called
#
def h6(name, identifier={:index => 0}, &block)
standard_methods(name, identifier, 'h6_for', &block)
define_method(name) do
@@ -978,18 +774,11 @@
# @example
# paragraph(:title, :id => 'title')
# # will generate 'title', 'title_element', and 'title?' methods
#
# @param [Symbol] the name used for the generated methods
- # @param [Hash] identifier how we find a paragraph. You can use a multiple parameters
- # by combining of any of the following except xpath. The valid keys are:
- # * :class => Watir and Selenium
- # * :css => Watir and Selenium
- # * :id => Watir and Selenium
- # * :index => Watir and Selenium
- # * :name => Watir and Selenium
- # * :xpath => Watir and Selenium
+ # @param [Hash] identifier how we find a paragraph.
# @param optional block to be invoked when element method is called
#
def paragraph(name, identifier={:index => 0}, &block)
standard_methods(name, identifier, 'paragraph_for', &block)
define_method(name) do
@@ -1006,20 +795,11 @@
# @example
# file_field(:the_file, :id => 'file_to_upload')
# # will generate 'the_file=', 'the_file_element', and 'the_file?' methods
#
# @param [Symbol] the name used for the generated methods
- # @param [Hash] identifier how we find a file_field. You can use a multiple parameters
- # by combining of any of the following except xpath. The valid keys are:
- # * :class => Watir and Selenium
- # * :css => Watir and Selenium
- # * :id => Watir and Selenium
- # * :index => Watir and Selenium
- # * :name => Watir and Selenium
- # * :title => Watir and Selenium
- # * :xpath => Watir and Selenium
- # * :label => Watir and Selenium
+ # @param [Hash] identifier how we find a file_field.
# @param optional block to be invoked when element method is called
#
def file_field(name, identifier={:index => 0}, &block)
standard_methods(name, identifier, 'file_field_for', &block)
define_method("#{name}=") do |value|
@@ -1035,19 +815,11 @@
# @example
# label(:message, :id => 'message')
# # will generate 'message', 'message_element', and 'message?' methods
#
# @param [Symbol] the name used for the generated methods
- # @param [Hash] identifier how we find a label. You can use a multiple parameters
- # by combining of any of the following except xpath. The valid keys are:
- # * :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
+ # @param [Hash] identifier how we find a label.
# @param optional block to be invoked when element method is called
#
def label(name, identifier={:index => 0}, &block)
standard_methods(name, identifier, 'label_for', &block)
define_method(name) do
@@ -1063,19 +835,11 @@
# @example
# area(:message, :id => 'message')
# # will generate 'message', 'message_element', and 'message?' methods
#
# @param [Symbol] the name used for the generated methods
- # @param [Hash] identifier how we find an area. You can use a multiple parameters
- # by combining of any of the following except xpath. The valid keys are:
- # * :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
+ # @param [Hash] identifier how we find an area.
# @param optional block to be invoked when element method is called
#
def area(name, identifier={:index => 0}, &block)
standard_methods(name, identifier, 'area_for', &block)
define_method(name) do
@@ -1091,18 +855,11 @@
# @example
# canvas(:my_canvas, :id => 'canvas_id')
# # will generate 'my_canvas_element' and 'my_canvas?' methods
#
# @param [Symbol] the name used for the generated methods
- # @param [Hash] identifier how we find a canvas. You can use a multiple parameters
- # by combining of any of the following except xpath. The valid keys are:
- # * :class => Watir and Selenium
- # * :css => Watir and Selenium
- # * :id => Watir and Selenium
- # * :index => Watir and Selenium
- # * :name => Watir and Selenium
- # * :xpath => Watir and Selenium
+ # @param [Hash] identifier how we find a canvas.
# @param optional block to be invoked when element method is called
#
def canvas(name, identifier={:index => 0}, &block)
standard_methods(name, identifier, 'canvas_for', &block)
end
@@ -1114,18 +871,11 @@
# @example
# audio(:acdc, :id => 'audio_id')
# # will generate 'acdc_element' and 'acdc?' methods
#
# @param [Symbol] the name used for the generated methods
- # @param [Hash] identifier how we find an audio element. You can use a multiple parameters
- # by combining of any of the following except xpath. The valid keys are:
- # * :class => Watir and Selenium
- # * :css => Watir and Selenium
- # * :id => Watir and Selenium
- # * :index => Watir and Selenium
- # * :name => Watir and Selenium
- # * :xpath => Watir and Selenium
+ # @param [Hash] identifier how we find an audio element.
# @param optional block to be invoked when element method is called
#
def audio(name, identifier={:index => 0}, &block)
standard_methods(name, identifier, 'audio_for', &block)
end
@@ -1137,18 +887,11 @@
# @example
# video(:movie, :id => 'video_id')
# # will generate 'movie_element' and 'movie?' methods
#
# @param [Symbol] the name used for the generated methods
- # @param [Hash] identifier how we find a video element. You can use a multiple parameters
- # by combining of any of the following except xpath. The valid keys are:
- # * :class => Watir and Selenium
- # * :css => Watir and Selenium
- # * :id => Watir and Selenium
- # * :index => Watir and Selenium
- # * :name => Watir and Selenium
- # * :xpath => Watir and Selenium
+ # @param [Hash] identifier how we find a video element.
# @param optional block to be invoked when element method is called
#
def video(name, identifier={:index => 0}, &block)
standard_methods(name, identifier, 'video_for', &block)
end
@@ -1160,18 +903,11 @@
# @example
# b(:bold, :id => 'title')
# # will generate 'bold', 'bold_element', and 'bold?' methods
#
# @param [Symbol] the name used for the generated methods
- # @param [Hash] identifier how we find a b. You can use a multiple parameters
- # by combining of any of the following except xpath. The valid keys are:
- # * :class => Watir and Selenium
- # * :css => Watir and Selenium
- # * :id => Watir and Selenium
- # * :index => Watir and Selenium
- # * :name => Watir and Selenium
- # * :xpath => Watir and Selenium
+ # @param [Hash] identifier how we find a b.
# @param optional block to be invoked when element method is called
#
def b(name, identifier={:index => 0}, &block)
standard_methods(name, identifier,'b_for', &block)
define_method(name) do
@@ -1187,18 +923,11 @@
# @example
# i(:italic, :id => 'title')
# # will generate 'italic', 'italic_element', and 'italic?' methods
#
# @param [Symbol] the name used for the generated methods
- # @param [Hash] identifier how we find a i. You can use a multiple parameters
- # by combining of any of the following except xpath. The valid keys are:
- # * :class => Watir and Selenium
- # * :css => Watir and Selenium
- # * :id => Watir and Selenium
- # * :index => Watir and Selenium
- # * :name => Watir and Selenium
- # * :xpath => Watir and Selenium
+ # @param [Hash] identifier how we find a i.
# @param optional block to be invoked when element method is called
#
def i(name, identifier={:index => 0}, &block)
standard_methods(name, identifier,'i_for', &block)
define_method(name) do
@@ -1215,18 +944,11 @@
# @example
# svg(:circle, :id => 'circle')
# # will generate 'circle_element', and 'circle?' methods
#
# @param [Symbol] the name used for the generated methods
- # @param [Hash] identifier how we find a svg. You can use a multiple parameters
- # by combining of any of the following except xpath. The valid keys are:
- # * :class => Watir and Selenium
- # * :css => Watir and Selenium
- # * :id => Watir and Selenium
- # * :index => Watir and Selenium
- # * :name => Watir and Selenium
- # * :xpath => Watir and Selenium
+ # @param [Hash] identifier how we find a svg.
# @param optional block to be invoked when element method is called
#
def svg(name, identifier={:index => 0}, &block)
standard_methods(name, identifier, 'svg_for', &block)
end
@@ -1240,18 +962,11 @@
# element(:title, :header, :id => 'title')
# # will generate 'title', 'title_element', and 'title?' methods
#
# @param [Symbol] the name used for the generated methods
# @param [Symbol] the name of the tag for the element
- # @param [Hash] identifier how we find an element. You can use a multiple parameters
- # by combining of any of the following except xpath. The valid keys are:
- # * :class => Watir and Selenium
- # * :css => Watir and Selenium
- # * :id => Watir and Selenium
- # * :index => Watir and Selenium
- # * :name => Watir and Selenium
- # * :xpath => Watir and Selenium
+ # @param [Hash] identifier how we find an element.
# @param optional block to be invoked when element method is called
#
def element(name, tag=:element, identifier={ :index => 0 }, &block)
#
# sets tag as element if not defined
@@ -1308,18 +1023,11 @@
# elements(:title, :header, :id => 'title')
# # will generate ''title_elements'
#
# @param [Symbol] the name used for the generated methods
# @param [Symbol] the name of the tag for the element
- # @param [Hash] identifier how we find an element. You can use a multiple parameters
- # by combining of any of the following except xpath. The valid keys are:
- # * :class => Watir and Selenium
- # * :css => Watir and Selenium
- # * :id => Watir and Selenium
- # * :index => Watir and Selenium
- # * :name => Watir and Selenium
- # * :xpath => Watir and Selenium
+ # @param [Hash] identifier how we find an element.
# @param optional block to be invoked when element method is called
#
def elements(name, tag=:element, identifier={:index => 0}, &block)
#
# sets tag as element if not defined
@@ -1338,22 +1046,15 @@
#
# adds a method to return a page object rooted at an element
#
# @example
# page_section(:navigation_bar, NavigationBar, :id => 'nav-bar')
- # # will generate 'navigation_bar' and 'navigation_bar?'
+ # # will generate 'navigation_bar'
#
# @param [Symbol] the name used for the generated methods
# @param [Class] the class to instantiate for the element
- # @param [Hash] identifier how we find an element. You can use multiple parameters
- # by combining of any of the following except xpath. The valid keys are:
- # * :class => Watir and Selenium
- # * :css => Watir and Selenium
- # * :id => Watir and Selenium
- # * :index => Watir and Selenium
- # * :name => Watir and Selenium
- # * :xpath => Watir and Selenium
+ # @param [Hash] identifier how we find an element.
#
def page_section(name, section_class, identifier)
define_method(name) do
platform.page_for(identifier, section_class)
end
@@ -1366,18 +1067,11 @@
# page_sections(:articles, Article, :class => 'article')
# # will generate 'articles'
#
# @param [Symbol] the name used for the generated method
# @param [Class] the class to instantiate for each element
- # @param [Hash] identifier how we find an element. You can use a multiple parameters
- # by combining of any of the following except xpath. The valid keys are:
- # * :class => Watir and Selenium
- # * :css => Watir and Selenium
- # * :id => Watir and Selenium
- # * :index => Watir and Selenium
- # * :name => Watir and Selenium
- # * :xpath => Watir and Selenium
+ # @param [Hash] identifier how we find an element.
#
def page_sections(name, section_class, identifier)
define_method(name) do
platform.pages_for(identifier, section_class)
end
@@ -1393,17 +1087,10 @@
# articles(:my_article, :id => 'article_id')
# will generate 'my_article_elements'
#
# @param [Symbol] the name used for the generated methods
# @param [Symbol] the name of the tag for the element
- # @param [Hash] identifier how we find an element. You can use a multiple parameters
- # by combining of any of the following except xpath. The valid keys are:
- # * :class => Watir and Selenium
- # * :css => Watir and Selenium
- # * :id => Watir and Selenium
- # * :index => Watir and Selenium
- # * :name => Watir and Selenium
- # * :xpath => Watir and Selenium
+ # @param [Hash] identifier how we find an element.
# @param optional block to be invoked when element method is called
#
LocatorGenerator::BASIC_ELEMENTS.each do |tag|
define_method(tag) do |name, *identifier, &block|
identifier = identifier[0] ? identifier[0] : {:index => 0}