lib/site-object/page.rb
# Used to define access to a single HTML element on a page. This method takes two arguments:
# * A symbol representing the element you are defining. This symbol is used to create an accessor
#   method on the page object.
# * A block where access to the HTML element gets defined.
#
# Example: The page you are working with has a "First Name" field:
#
#  element(:first_name) { |b| b.text_field(:id 'signup-first-name') }
#
# In the example above,  the block argument 'b' is the browser object that will get passed down from
# the site to the page and used when the page needs to access the element. You can actually use any
# label for the block argument but it's recommended that you use something like 'b' or 'browser'
# consistently here because it's always going to be some sort of browser object.
#
# When page objects get initialized they'll create an accessor method for the element and you can
# then work with the element in the same way you'd work with it in Watir or Selenium.
#
# The element method is aliased to 'el' and using this alias is recommended as it saves space:
#
#  el(:first_name) { |b| b.text_field(:id 'signup-first-name') }
Used to define access to a single HTML element on a page. This method takes two arguments:
A symbol representing the element you are defining. This symbol is used to create an accessor
method on the page object.
A block where access to the HTML element gets defined.

The page you are working with has a "First Name" field.



In the example above,  the block argument 'b' is the browser object that will get passed down from
the site to the page and used when the page needs to access the element.

When page objects get initialized they'll create an accessor method for the element and you can
then work with the element in the same way you'd work with it in Watir or Selenium.

The element method is aliased to 'el' and using this alias is recommended as it saves space.


Used to define access to a single HTML element on a page . This method takes two arguments : A symbol representing the element you are defining . This symbol is used to create an accessor method on the page object . A block where access to the HTML element gets defined . The page you are working with has a " First Name " field . In the example above the block argument ' b ' is the browser object that will get passed down from the site to the page and used when the page needs to access the element . When page objects get initialized they ' ll create an accessor method for the element and you can then work with the element in the same way you ' d work with it in Watir or Selenium . The element method is aliased to ' el ' and using this alias is recommended as it saves space .
def element(name, &block)
      @page_elements ||= []
      @page_elements << name.to_sym
      define_method(name) do
        block.call(@browser)
      end
    end
def element ( name , & block ) @page_elements ||= [ ] @page_elements << name . to_sym define_method ( name ) do block . call ( @browser ) end end
Used to define access to a single HTML element on a page.
Used to define access to a single HTML element on a page .
name
<not_specific>
block
<not_specific>