page-object 0.0.3 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/ChangeLog +10 -1
 - data/Gemfile +3 -0
 - data/README.md +2 -2
 - data/cucumber.yml +2 -0
 - data/features/element.feature +81 -8
 - data/features/form.feature +28 -0
 - data/features/hidden_field.feature +32 -0
 - data/features/html/static_elements.html +26 -0
 - data/features/list_item.feature +36 -0
 - data/features/ordered_list.feature +39 -0
 - data/features/step_definitions/accessor_steps.rb +71 -0
 - data/features/step_definitions/element_steps.rb +23 -0
 - data/features/support/page.rb +43 -0
 - data/features/text_area.feature +32 -0
 - data/features/text_field.feature +1 -2
 - data/features/unordered_list.feature +39 -0
 - data/lib/page-object.rb +48 -3
 - data/lib/page-object/accessors.rb +282 -111
 - data/lib/page-object/elements.rb +6 -0
 - data/lib/page-object/elements/element.rb +5 -1
 - data/lib/page-object/elements/form.rb +25 -0
 - data/lib/page-object/elements/hidden_field.rb +28 -0
 - data/lib/page-object/elements/list_item.rb +7 -0
 - data/lib/page-object/elements/ordered_list.rb +31 -0
 - data/lib/page-object/elements/text_area.rb +24 -0
 - data/lib/page-object/elements/text_field.rb +1 -1
 - data/lib/page-object/elements/unordered_list.rb +31 -0
 - data/lib/page-object/platforms/selenium_button.rb +1 -1
 - data/lib/page-object/platforms/selenium_element.rb +3 -0
 - data/lib/page-object/platforms/selenium_form.rb +14 -0
 - data/lib/page-object/platforms/selenium_image.rb +6 -2
 - data/lib/page-object/platforms/selenium_ordered_list.rb +18 -0
 - data/lib/page-object/platforms/selenium_unordered_list.rb +18 -0
 - data/lib/page-object/platforms/watir_element.rb +3 -0
 - data/lib/page-object/platforms/watir_form.rb +14 -0
 - data/lib/page-object/platforms/watir_ordered_list.rb +18 -0
 - data/lib/page-object/platforms/watir_unordered_list.rb +18 -0
 - data/lib/page-object/selenium_page_object.rb +101 -0
 - data/lib/page-object/version.rb +2 -1
 - data/lib/page-object/watir_page_object.rb +103 -2
 - data/spec/page-object/accessors_spec.rb +203 -2
 - data/spec/page-object/elements/form_spec.rb +24 -0
 - data/spec/page-object/elements/hidden_field_spec.rb +32 -0
 - data/spec/page-object/elements/list_item_spec.rb +22 -0
 - data/spec/page-object/elements/ordered_list_spec.rb +43 -0
 - data/spec/page-object/elements/text_area_spec.rb +32 -0
 - data/spec/page-object/elements/text_field_spec.rb +1 -1
 - data/spec/page-object/elements/unordered_list_spec.rb +43 -0
 - metadata +39 -5
 
    
        data/lib/page-object/elements.rb
    CHANGED
    
    | 
         @@ -12,3 +12,9 @@ require 'page-object/elements/table_cell' 
     | 
|
| 
       12 
12 
     | 
    
         
             
            require 'page-object/elements/table_row'
         
     | 
| 
       13 
13 
     | 
    
         
             
            require 'page-object/elements/span'
         
     | 
| 
       14 
14 
     | 
    
         
             
            require 'page-object/elements/image'
         
     | 
| 
      
 15 
     | 
    
         
            +
            require 'page-object/elements/hidden_field'
         
     | 
| 
      
 16 
     | 
    
         
            +
            require 'page-object/elements/form'
         
     | 
| 
      
 17 
     | 
    
         
            +
            require 'page-object/elements/text_area'
         
     | 
| 
      
 18 
     | 
    
         
            +
            require 'page-object/elements/list_item'
         
     | 
| 
      
 19 
     | 
    
         
            +
            require 'page-object/elements/unordered_list'
         
     | 
| 
      
 20 
     | 
    
         
            +
            require 'page-object/elements/ordered_list'
         
     | 
| 
         @@ -1,10 +1,12 @@ 
     | 
|
| 
       1 
1 
     | 
    
         | 
| 
       2 
2 
     | 
    
         
             
            module PageObject
         
     | 
| 
       3 
3 
     | 
    
         
             
              module Elements
         
     | 
| 
       4 
     | 
    
         
            -
             
     | 
| 
       5 
4 
     | 
    
         
             
                #
         
     | 
| 
       6 
5 
     | 
    
         
             
                # Contains functionality that is common across all elements.
         
     | 
| 
       7 
6 
     | 
    
         
             
                #
         
     | 
| 
      
 7 
     | 
    
         
            +
                # @see PageObject::Platforms::WatirElement for the Watir version of all common methods
         
     | 
| 
      
 8 
     | 
    
         
            +
                # @see PageObject::Platforms::SeleniumElement for the Selenium version of all common methods
         
     | 
| 
      
 9 
     | 
    
         
            +
                #
         
     | 
| 
       8 
10 
     | 
    
         
             
                class Element
         
     | 
| 
       9 
11 
     | 
    
         
             
                  attr_reader :element
         
     | 
| 
       10 
12 
     | 
    
         | 
| 
         @@ -13,10 +15,12 @@ module PageObject 
     | 
|
| 
       13 
15 
     | 
    
         
             
                    include_platform_for platform
         
     | 
| 
       14 
16 
     | 
    
         
             
                  end
         
     | 
| 
       15 
17 
     | 
    
         | 
| 
      
 18 
     | 
    
         
            +
                  # @private
         
     | 
| 
       16 
19 
     | 
    
         
             
                  def self.watir_identifier_for identifier
         
     | 
| 
       17 
20 
     | 
    
         
             
                    identifier_for identifier, watir_finders, watir_mapping
         
     | 
| 
       18 
21 
     | 
    
         
             
                  end
         
     | 
| 
       19 
22 
     | 
    
         | 
| 
      
 23 
     | 
    
         
            +
                  # @private
         
     | 
| 
       20 
24 
     | 
    
         
             
                  def self.selenium_identifier_for identifier
         
     | 
| 
       21 
25 
     | 
    
         
             
                    identifier = identifier_for identifier, selenium_finders, selenium_mapping
         
     | 
| 
       22 
26 
     | 
    
         
             
                    return identifier.keys.first, identifier.values.first
         
     | 
| 
         @@ -0,0 +1,25 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            module PageObject
         
     | 
| 
      
 2 
     | 
    
         
            +
              module Elements
         
     | 
| 
      
 3 
     | 
    
         
            +
                class Form < Element
         
     | 
| 
      
 4 
     | 
    
         
            +
                  def initialize(element, platform)
         
     | 
| 
      
 5 
     | 
    
         
            +
                    @element = element
         
     | 
| 
      
 6 
     | 
    
         
            +
                    include_platform_for platform
         
     | 
| 
      
 7 
     | 
    
         
            +
                  end
         
     | 
| 
      
 8 
     | 
    
         
            +
                  
         
     | 
| 
      
 9 
     | 
    
         
            +
                  protected
         
     | 
| 
      
 10 
     | 
    
         
            +
                  
         
     | 
| 
      
 11 
     | 
    
         
            +
                  def include_platform_for platform
         
     | 
| 
      
 12 
     | 
    
         
            +
                    super
         
     | 
| 
      
 13 
     | 
    
         
            +
                    if platform[:platform] == :watir
         
     | 
| 
      
 14 
     | 
    
         
            +
                      require 'page-object/platforms/watir_form'
         
     | 
| 
      
 15 
     | 
    
         
            +
                      self.class.send :include, PageObject::Platforms::WatirForm
         
     | 
| 
      
 16 
     | 
    
         
            +
                    elsif platform[:platform] == :selenium
         
     | 
| 
      
 17 
     | 
    
         
            +
                      require 'page-object/platforms/selenium_form'
         
     | 
| 
      
 18 
     | 
    
         
            +
                      self.class.send :include, PageObject::Platforms::SeleniumForm
         
     | 
| 
      
 19 
     | 
    
         
            +
                    else
         
     | 
| 
      
 20 
     | 
    
         
            +
                      raise ArgumentError, "expect platform to be :watir or :selenium"          
         
     | 
| 
      
 21 
     | 
    
         
            +
                    end
         
     | 
| 
      
 22 
     | 
    
         
            +
                  end
         
     | 
| 
      
 23 
     | 
    
         
            +
                end
         
     | 
| 
      
 24 
     | 
    
         
            +
              end
         
     | 
| 
      
 25 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,28 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            module PageObject
         
     | 
| 
      
 2 
     | 
    
         
            +
              module Elements
         
     | 
| 
      
 3 
     | 
    
         
            +
                class HiddenField < Element
         
     | 
| 
      
 4 
     | 
    
         
            +
                  
         
     | 
| 
      
 5 
     | 
    
         
            +
                  def click
         
     | 
| 
      
 6 
     | 
    
         
            +
                    raise "click is not available on hidden field element with Selenium or Watir"
         
     | 
| 
      
 7 
     | 
    
         
            +
                  end
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
                  protected
         
     | 
| 
      
 10 
     | 
    
         
            +
                  
         
     | 
| 
      
 11 
     | 
    
         
            +
                  def self.watir_finders
         
     | 
| 
      
 12 
     | 
    
         
            +
                    super + [:tag_name, :text]
         
     | 
| 
      
 13 
     | 
    
         
            +
                  end
         
     | 
| 
      
 14 
     | 
    
         
            +
                  
         
     | 
| 
      
 15 
     | 
    
         
            +
                  def self.watir_mapping
         
     | 
| 
      
 16 
     | 
    
         
            +
                    super.merge({:css => :tag_name})
         
     | 
| 
      
 17 
     | 
    
         
            +
                  end
         
     | 
| 
      
 18 
     | 
    
         
            +
                  
         
     | 
| 
      
 19 
     | 
    
         
            +
                  def self.selenium_finders
         
     | 
| 
      
 20 
     | 
    
         
            +
                    super + [:css]
         
     | 
| 
      
 21 
     | 
    
         
            +
                  end
         
     | 
| 
      
 22 
     | 
    
         
            +
                  
         
     | 
| 
      
 23 
     | 
    
         
            +
                  def self.selenium_mapping
         
     | 
| 
      
 24 
     | 
    
         
            +
                    super.merge({:tag_name => :css})
         
     | 
| 
      
 25 
     | 
    
         
            +
                  end
         
     | 
| 
      
 26 
     | 
    
         
            +
                end
         
     | 
| 
      
 27 
     | 
    
         
            +
              end
         
     | 
| 
      
 28 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,31 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            module PageObject
         
     | 
| 
      
 2 
     | 
    
         
            +
              module Elements
         
     | 
| 
      
 3 
     | 
    
         
            +
                class OrderedList < Element
         
     | 
| 
      
 4 
     | 
    
         
            +
                  
         
     | 
| 
      
 5 
     | 
    
         
            +
                  def initialize(element, platform)
         
     | 
| 
      
 6 
     | 
    
         
            +
                    @element = element
         
     | 
| 
      
 7 
     | 
    
         
            +
                    include_platform_for platform
         
     | 
| 
      
 8 
     | 
    
         
            +
                  end
         
     | 
| 
      
 9 
     | 
    
         
            +
                  
         
     | 
| 
      
 10 
     | 
    
         
            +
                  protected
         
     | 
| 
      
 11 
     | 
    
         
            +
                  
         
     | 
| 
      
 12 
     | 
    
         
            +
                  def self.watir_finders
         
     | 
| 
      
 13 
     | 
    
         
            +
                    [:class, :id, :index, :xpath]
         
     | 
| 
      
 14 
     | 
    
         
            +
                  end
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
      
 16 
     | 
    
         
            +
                  def include_platform_for platform
         
     | 
| 
      
 17 
     | 
    
         
            +
                    super
         
     | 
| 
      
 18 
     | 
    
         
            +
                    if platform[:platform] == :watir
         
     | 
| 
      
 19 
     | 
    
         
            +
                      require 'page-object/platforms/watir_ordered_list'
         
     | 
| 
      
 20 
     | 
    
         
            +
                      self.class.send :include, PageObject::Platforms::WatirOrderedList
         
     | 
| 
      
 21 
     | 
    
         
            +
                    elsif platform[:platform] == :selenium
         
     | 
| 
      
 22 
     | 
    
         
            +
                      require 'page-object/platforms/selenium_ordered_list'
         
     | 
| 
      
 23 
     | 
    
         
            +
                      self.class.send :include, PageObject::Platforms::SeleniumOrderedList
         
     | 
| 
      
 24 
     | 
    
         
            +
                    else
         
     | 
| 
      
 25 
     | 
    
         
            +
                      raise ArgumentError, "expect platform to be :watir or :selenium"          
         
     | 
| 
      
 26 
     | 
    
         
            +
                    end
         
     | 
| 
      
 27 
     | 
    
         
            +
                  end
         
     | 
| 
      
 28 
     | 
    
         
            +
              
         
     | 
| 
      
 29 
     | 
    
         
            +
                end
         
     | 
| 
      
 30 
     | 
    
         
            +
              end
         
     | 
| 
      
 31 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,24 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            module PageObject
         
     | 
| 
      
 2 
     | 
    
         
            +
              module Elements
         
     | 
| 
      
 3 
     | 
    
         
            +
                class TextArea < Element
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
                  protected
         
     | 
| 
      
 6 
     | 
    
         
            +
                  
         
     | 
| 
      
 7 
     | 
    
         
            +
                  def self.watir_finders
         
     | 
| 
      
 8 
     | 
    
         
            +
                    super + [:tag_name]
         
     | 
| 
      
 9 
     | 
    
         
            +
                  end
         
     | 
| 
      
 10 
     | 
    
         
            +
                  
         
     | 
| 
      
 11 
     | 
    
         
            +
                  def self.watir_mapping
         
     | 
| 
      
 12 
     | 
    
         
            +
                    super.merge({:css => :tag_name})
         
     | 
| 
      
 13 
     | 
    
         
            +
                  end
         
     | 
| 
      
 14 
     | 
    
         
            +
                  
         
     | 
| 
      
 15 
     | 
    
         
            +
                  def self.selenium_finders
         
     | 
| 
      
 16 
     | 
    
         
            +
                    super + [:css]
         
     | 
| 
      
 17 
     | 
    
         
            +
                  end
         
     | 
| 
      
 18 
     | 
    
         
            +
                  
         
     | 
| 
      
 19 
     | 
    
         
            +
                  def self.selenium_mapping
         
     | 
| 
      
 20 
     | 
    
         
            +
                    super.merge({:tag_name => :css})
         
     | 
| 
      
 21 
     | 
    
         
            +
                  end
         
     | 
| 
      
 22 
     | 
    
         
            +
                end
         
     | 
| 
      
 23 
     | 
    
         
            +
              end
         
     | 
| 
      
 24 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,31 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            module PageObject
         
     | 
| 
      
 2 
     | 
    
         
            +
              module Elements
         
     | 
| 
      
 3 
     | 
    
         
            +
                class UnorderedList < Element
         
     | 
| 
      
 4 
     | 
    
         
            +
                  
         
     | 
| 
      
 5 
     | 
    
         
            +
                  def initialize(element, platform)
         
     | 
| 
      
 6 
     | 
    
         
            +
                    @element = element
         
     | 
| 
      
 7 
     | 
    
         
            +
                    include_platform_for platform
         
     | 
| 
      
 8 
     | 
    
         
            +
                  end
         
     | 
| 
      
 9 
     | 
    
         
            +
                  
         
     | 
| 
      
 10 
     | 
    
         
            +
                  protected
         
     | 
| 
      
 11 
     | 
    
         
            +
                  
         
     | 
| 
      
 12 
     | 
    
         
            +
                  def self.watir_finders
         
     | 
| 
      
 13 
     | 
    
         
            +
                    [:class, :id, :index, :xpath]
         
     | 
| 
      
 14 
     | 
    
         
            +
                  end
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
      
 16 
     | 
    
         
            +
                  def include_platform_for platform
         
     | 
| 
      
 17 
     | 
    
         
            +
                    super
         
     | 
| 
      
 18 
     | 
    
         
            +
                    if platform[:platform] == :watir
         
     | 
| 
      
 19 
     | 
    
         
            +
                      require 'page-object/platforms/watir_unordered_list'
         
     | 
| 
      
 20 
     | 
    
         
            +
                      self.class.send :include, PageObject::Platforms::WatirUnorderedList
         
     | 
| 
      
 21 
     | 
    
         
            +
                    elsif platform[:platform] == :selenium
         
     | 
| 
      
 22 
     | 
    
         
            +
                      require 'page-object/platforms/selenium_unordered_list'
         
     | 
| 
      
 23 
     | 
    
         
            +
                      self.class.send :include, PageObject::Platforms::SeleniumUnorderedList
         
     | 
| 
      
 24 
     | 
    
         
            +
                    else
         
     | 
| 
      
 25 
     | 
    
         
            +
                      raise ArgumentError, "expect platform to be :watir or :selenium"          
         
     | 
| 
      
 26 
     | 
    
         
            +
                    end
         
     | 
| 
      
 27 
     | 
    
         
            +
                  end
         
     | 
| 
      
 28 
     | 
    
         
            +
              
         
     | 
| 
      
 29 
     | 
    
         
            +
                end
         
     | 
| 
      
 30 
     | 
    
         
            +
              end
         
     | 
| 
      
 31 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -6,7 +6,6 @@ module PageObject 
     | 
|
| 
       6 
6 
     | 
    
         
             
                  # Return the width of the image.
         
     | 
| 
       7 
7 
     | 
    
         
             
                  #
         
     | 
| 
       8 
8 
     | 
    
         
             
                  def width
         
     | 
| 
       9 
     | 
    
         
            -
                    dimension = @element.size
         
     | 
| 
       10 
9 
     | 
    
         
             
                    dimension.width
         
     | 
| 
       11 
10 
     | 
    
         
             
                  end
         
     | 
| 
       12 
11 
     | 
    
         | 
| 
         @@ -14,9 +13,14 @@ module PageObject 
     | 
|
| 
       14 
13 
     | 
    
         
             
                  # Return the height of the image
         
     | 
| 
       15 
14 
     | 
    
         
             
                  #
         
     | 
| 
       16 
15 
     | 
    
         
             
                  def height
         
     | 
| 
       17 
     | 
    
         
            -
                    dimension = @element.size
         
     | 
| 
       18 
16 
     | 
    
         
             
                    dimension.height
         
     | 
| 
       19 
17 
     | 
    
         
             
                  end
         
     | 
| 
      
 18 
     | 
    
         
            +
                  
         
     | 
| 
      
 19 
     | 
    
         
            +
                  private
         
     | 
| 
      
 20 
     | 
    
         
            +
                  
         
     | 
| 
      
 21 
     | 
    
         
            +
                  def dimension
         
     | 
| 
      
 22 
     | 
    
         
            +
                    @element.size
         
     | 
| 
      
 23 
     | 
    
         
            +
                  end
         
     | 
| 
       20 
24 
     | 
    
         
             
                end
         
     | 
| 
       21 
25 
     | 
    
         
             
              end
         
     | 
| 
       22 
26 
     | 
    
         
             
            end
         
     | 
| 
         @@ -0,0 +1,18 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            module PageObject
         
     | 
| 
      
 2 
     | 
    
         
            +
              module Platforms
         
     | 
| 
      
 3 
     | 
    
         
            +
                module SeleniumOrderedList
         
     | 
| 
      
 4 
     | 
    
         
            +
                  
         
     | 
| 
      
 5 
     | 
    
         
            +
                  #
         
     | 
| 
      
 6 
     | 
    
         
            +
                  # Return the PageObject::Elements::ListItem for the index provided.  Index
         
     | 
| 
      
 7 
     | 
    
         
            +
                  # is zero based.
         
     | 
| 
      
 8 
     | 
    
         
            +
                  #
         
     | 
| 
      
 9 
     | 
    
         
            +
                  # @return [PageObject::Elements::ListItem]
         
     | 
| 
      
 10 
     | 
    
         
            +
                  #
         
     | 
| 
      
 11 
     | 
    
         
            +
                  def [](idx)
         
     | 
| 
      
 12 
     | 
    
         
            +
                    element = @element.find_element(:xpath, ".//li[#{idx+1}]")
         
     | 
| 
      
 13 
     | 
    
         
            +
                    PageObject::Elements::ListItem.new(element, :platform => :selenium)
         
     | 
| 
      
 14 
     | 
    
         
            +
                  end
         
     | 
| 
      
 15 
     | 
    
         
            +
                  
         
     | 
| 
      
 16 
     | 
    
         
            +
                end
         
     | 
| 
      
 17 
     | 
    
         
            +
              end
         
     | 
| 
      
 18 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,18 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            module PageObject
         
     | 
| 
      
 2 
     | 
    
         
            +
              module Platforms
         
     | 
| 
      
 3 
     | 
    
         
            +
                module SeleniumUnorderedList
         
     | 
| 
      
 4 
     | 
    
         
            +
                  
         
     | 
| 
      
 5 
     | 
    
         
            +
                  #
         
     | 
| 
      
 6 
     | 
    
         
            +
                  # Return the PageObject::Elements::ListItem for the index provided.  Index
         
     | 
| 
      
 7 
     | 
    
         
            +
                  # is zero based.
         
     | 
| 
      
 8 
     | 
    
         
            +
                  #
         
     | 
| 
      
 9 
     | 
    
         
            +
                  # @return [PageObject::Elements::ListItem]
         
     | 
| 
      
 10 
     | 
    
         
            +
                  #
         
     | 
| 
      
 11 
     | 
    
         
            +
                  def [](idx)
         
     | 
| 
      
 12 
     | 
    
         
            +
                    element = @element.find_element(:xpath, ".//li[#{idx+1}]")
         
     | 
| 
      
 13 
     | 
    
         
            +
                    PageObject::Elements::ListItem.new(element, :platform => :selenium)
         
     | 
| 
      
 14 
     | 
    
         
            +
                  end
         
     | 
| 
      
 15 
     | 
    
         
            +
                  
         
     | 
| 
      
 16 
     | 
    
         
            +
                end
         
     | 
| 
      
 17 
     | 
    
         
            +
              end
         
     | 
| 
      
 18 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,18 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            module PageObject
         
     | 
| 
      
 2 
     | 
    
         
            +
              module Platforms
         
     | 
| 
      
 3 
     | 
    
         
            +
                module WatirOrderedList
         
     | 
| 
      
 4 
     | 
    
         
            +
                  
         
     | 
| 
      
 5 
     | 
    
         
            +
                  #
         
     | 
| 
      
 6 
     | 
    
         
            +
                  # Return the PageObject::Elements::ListItem for the index provided.  Index
         
     | 
| 
      
 7 
     | 
    
         
            +
                  # is zero based.
         
     | 
| 
      
 8 
     | 
    
         
            +
                  #
         
     | 
| 
      
 9 
     | 
    
         
            +
                  # @return [PageObject::Elements::ListItem]
         
     | 
| 
      
 10 
     | 
    
         
            +
                  #
         
     | 
| 
      
 11 
     | 
    
         
            +
                  def [](idx)
         
     | 
| 
      
 12 
     | 
    
         
            +
                    element = @element.wd.find_element(:xpath, ".//li[#{idx+1}]")
         
     | 
| 
      
 13 
     | 
    
         
            +
                    PageObject::Elements::ListItem.new(element, :platform => :watir)
         
     | 
| 
      
 14 
     | 
    
         
            +
                  end
         
     | 
| 
      
 15 
     | 
    
         
            +
                  
         
     | 
| 
      
 16 
     | 
    
         
            +
                end
         
     | 
| 
      
 17 
     | 
    
         
            +
              end
         
     | 
| 
      
 18 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,18 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            module PageObject
         
     | 
| 
      
 2 
     | 
    
         
            +
              module Platforms
         
     | 
| 
      
 3 
     | 
    
         
            +
                module WatirUnorderedList
         
     | 
| 
      
 4 
     | 
    
         
            +
                  
         
     | 
| 
      
 5 
     | 
    
         
            +
                  #
         
     | 
| 
      
 6 
     | 
    
         
            +
                  # Return the PageObject::Elements::ListItem for the index provided.  Index
         
     | 
| 
      
 7 
     | 
    
         
            +
                  # is zero based.
         
     | 
| 
      
 8 
     | 
    
         
            +
                  #
         
     | 
| 
      
 9 
     | 
    
         
            +
                  # @return [PageObject::Elements::ListItem]
         
     | 
| 
      
 10 
     | 
    
         
            +
                  #
         
     | 
| 
      
 11 
     | 
    
         
            +
                  def [](idx)
         
     | 
| 
      
 12 
     | 
    
         
            +
                    element = @element.wd.find_element(:xpath, ".//li[#{idx+1}]")
         
     | 
| 
      
 13 
     | 
    
         
            +
                    PageObject::Elements::ListItem.new(element, :platform => :watir)
         
     | 
| 
      
 14 
     | 
    
         
            +
                  end
         
     | 
| 
      
 15 
     | 
    
         
            +
                  
         
     | 
| 
      
 16 
     | 
    
         
            +
                end
         
     | 
| 
      
 17 
     | 
    
         
            +
              end
         
     | 
| 
      
 18 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -1,6 +1,11 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            require 'page-object/elements'
         
     | 
| 
       2 
2 
     | 
    
         | 
| 
       3 
3 
     | 
    
         
             
            module PageObject
         
     | 
| 
      
 4 
     | 
    
         
            +
              #
         
     | 
| 
      
 5 
     | 
    
         
            +
              # Selenium implementation of the page object platform driver.  You should not use the
         
     | 
| 
      
 6 
     | 
    
         
            +
              # class directly.  Instead you should include the PageObject module in your page object
         
     | 
| 
      
 7 
     | 
    
         
            +
              # and use the methods dynamically added from the PageObject::Accessors module.
         
     | 
| 
      
 8 
     | 
    
         
            +
              #
         
     | 
| 
       4 
9 
     | 
    
         
             
              class SeleniumPageObject
         
     | 
| 
       5 
10 
     | 
    
         
             
                def initialize(browser)
         
     | 
| 
       6 
11 
     | 
    
         
             
                  @browser = browser
         
     | 
| 
         @@ -66,6 +71,53 @@ module PageObject 
     | 
|
| 
       66 
71 
     | 
    
         
             
                  PageObject::Elements::TextField.new(element, :platform => :selenium)
         
     | 
| 
       67 
72 
     | 
    
         
             
                end
         
     | 
| 
       68 
73 
     | 
    
         | 
| 
      
 74 
     | 
    
         
            +
                #
         
     | 
| 
      
 75 
     | 
    
         
            +
                # platform method to get the value stored in a hidden field
         
     | 
| 
      
 76 
     | 
    
         
            +
                # See PageObject::Accessors#hidden_field
         
     | 
| 
      
 77 
     | 
    
         
            +
                #
         
     | 
| 
      
 78 
     | 
    
         
            +
                def hidden_field_value_for(identifier)
         
     | 
| 
      
 79 
     | 
    
         
            +
                  how, what = Elements::HiddenField.selenium_identifier_for identifier
         
     | 
| 
      
 80 
     | 
    
         
            +
                  @browser.find_element(how, what).attribute('value')
         
     | 
| 
      
 81 
     | 
    
         
            +
                end
         
     | 
| 
      
 82 
     | 
    
         
            +
                
         
     | 
| 
      
 83 
     | 
    
         
            +
                #
         
     | 
| 
      
 84 
     | 
    
         
            +
                # platform method to retrieve a hidden field element
         
     | 
| 
      
 85 
     | 
    
         
            +
                # See PageObject::Accessors#hidden_field
         
     | 
| 
      
 86 
     | 
    
         
            +
                #
         
     | 
| 
      
 87 
     | 
    
         
            +
                def hidden_field_for(identifier)
         
     | 
| 
      
 88 
     | 
    
         
            +
                  how, what = Elements::HiddenField.selenium_identifier_for identifier
         
     | 
| 
      
 89 
     | 
    
         
            +
                  element = @browser.find_element(how, what)
         
     | 
| 
      
 90 
     | 
    
         
            +
                  Elements::HiddenField.new(element, :platform => :selenium)
         
     | 
| 
      
 91 
     | 
    
         
            +
                end    
         
     | 
| 
      
 92 
     | 
    
         
            +
             
     | 
| 
      
 93 
     | 
    
         
            +
                #
         
     | 
| 
      
 94 
     | 
    
         
            +
                # platform method to set text in a textarea
         
     | 
| 
      
 95 
     | 
    
         
            +
                # See PageObject::Accessors#text_area
         
     | 
| 
      
 96 
     | 
    
         
            +
                #
         
     | 
| 
      
 97 
     | 
    
         
            +
                def text_area_value_set(identifier, value)
         
     | 
| 
      
 98 
     | 
    
         
            +
                  how, what = Elements::TextArea.selenium_identifier_for identifier
         
     | 
| 
      
 99 
     | 
    
         
            +
                  @browser.find_element(how, what).send_keys(value)
         
     | 
| 
      
 100 
     | 
    
         
            +
                end
         
     | 
| 
      
 101 
     | 
    
         
            +
                
         
     | 
| 
      
 102 
     | 
    
         
            +
                #
         
     | 
| 
      
 103 
     | 
    
         
            +
                # platform method to get the text from a textarea
         
     | 
| 
      
 104 
     | 
    
         
            +
                # See PageObject::Accessors#text_area
         
     | 
| 
      
 105 
     | 
    
         
            +
                #
         
     | 
| 
      
 106 
     | 
    
         
            +
                def text_area_value_for(identifier)
         
     | 
| 
      
 107 
     | 
    
         
            +
                  how, what = Elements::TextArea.selenium_identifier_for identifier
         
     | 
| 
      
 108 
     | 
    
         
            +
                  @browser.find_element(how, what).attribute('value')
         
     | 
| 
      
 109 
     | 
    
         
            +
                end
         
     | 
| 
      
 110 
     | 
    
         
            +
                
         
     | 
| 
      
 111 
     | 
    
         
            +
                #
         
     | 
| 
      
 112 
     | 
    
         
            +
                # platform method to get the text area element
         
     | 
| 
      
 113 
     | 
    
         
            +
                # See PageObject::Accessors#text_area
         
     | 
| 
      
 114 
     | 
    
         
            +
                #
         
     | 
| 
      
 115 
     | 
    
         
            +
                def text_area_for(identifier)
         
     | 
| 
      
 116 
     | 
    
         
            +
                  how, what = Elements::TextArea.selenium_identifier_for identifier
         
     | 
| 
      
 117 
     | 
    
         
            +
                  element = @browser.find_element(how, what)
         
     | 
| 
      
 118 
     | 
    
         
            +
                  Elements::TextArea.new(element, :platform => :selenium)
         
     | 
| 
      
 119 
     | 
    
         
            +
                end
         
     | 
| 
      
 120 
     | 
    
         
            +
                
         
     | 
| 
       69 
121 
     | 
    
         
             
                #
         
     | 
| 
       70 
122 
     | 
    
         
             
                # platform method to get the currently selected value from a select list
         
     | 
| 
       71 
123 
     | 
    
         
             
                # See PageObject::Accessors#select_list
         
     | 
| 
         @@ -282,5 +334,54 @@ module PageObject 
     | 
|
| 
       282 
334 
     | 
    
         
             
                  element = @browser.find_element(how, what)
         
     | 
| 
       283 
335 
     | 
    
         
             
                  PageObject::Elements::Image.new(element, :platform => :selenium)
         
     | 
| 
       284 
336 
     | 
    
         
             
                end
         
     | 
| 
      
 337 
     | 
    
         
            +
                
         
     | 
| 
      
 338 
     | 
    
         
            +
                #
         
     | 
| 
      
 339 
     | 
    
         
            +
                # platform method to retrieve a form element
         
     | 
| 
      
 340 
     | 
    
         
            +
                # See PageObject::Accessors#form
         
     | 
| 
      
 341 
     | 
    
         
            +
                #
         
     | 
| 
      
 342 
     | 
    
         
            +
                def form_for(identifier)
         
     | 
| 
      
 343 
     | 
    
         
            +
                  how, what = Elements::Form.selenium_identifier_for identifier
         
     | 
| 
      
 344 
     | 
    
         
            +
                  element = @browser.find_element(how, what)
         
     | 
| 
      
 345 
     | 
    
         
            +
                  PageObject::Elements::Form.new(element, :platform => :selenium)
         
     | 
| 
      
 346 
     | 
    
         
            +
                end
         
     | 
| 
      
 347 
     | 
    
         
            +
             
     | 
| 
      
 348 
     | 
    
         
            +
                #
         
     | 
| 
      
 349 
     | 
    
         
            +
                # platform method to retrieve the text from a list item
         
     | 
| 
      
 350 
     | 
    
         
            +
                # See PageObject::Accessors#list_item
         
     | 
| 
      
 351 
     | 
    
         
            +
                #
         
     | 
| 
      
 352 
     | 
    
         
            +
                def list_item_text_for(identifier)
         
     | 
| 
      
 353 
     | 
    
         
            +
                  how, what = Elements::ListItem.selenium_identifier_for identifier
         
     | 
| 
      
 354 
     | 
    
         
            +
                  @browser.find_element(how, what).text
         
     | 
| 
      
 355 
     | 
    
         
            +
                end
         
     | 
| 
      
 356 
     | 
    
         
            +
                
         
     | 
| 
      
 357 
     | 
    
         
            +
                #
         
     | 
| 
      
 358 
     | 
    
         
            +
                # platform method to retrieve a list item element
         
     | 
| 
      
 359 
     | 
    
         
            +
                # See PageObject::Accessors#list_item
         
     | 
| 
      
 360 
     | 
    
         
            +
                #
         
     | 
| 
      
 361 
     | 
    
         
            +
                def list_item_for(identifier)
         
     | 
| 
      
 362 
     | 
    
         
            +
                  how, what = Elements::ListItem.selenium_identifier_for identifier
         
     | 
| 
      
 363 
     | 
    
         
            +
                  element = @browser.find_element(how, what)
         
     | 
| 
      
 364 
     | 
    
         
            +
                  PageObject::Elements::ListItem.new(element, :platform => :selenium)
         
     | 
| 
      
 365 
     | 
    
         
            +
                end
         
     | 
| 
      
 366 
     | 
    
         
            +
                
         
     | 
| 
      
 367 
     | 
    
         
            +
                #
         
     | 
| 
      
 368 
     | 
    
         
            +
                # platform method to retrieve an unordered list element
         
     | 
| 
      
 369 
     | 
    
         
            +
                # See PageObject::Accessors#unordered_list
         
     | 
| 
      
 370 
     | 
    
         
            +
                #
         
     | 
| 
      
 371 
     | 
    
         
            +
                def unordered_list_for(identifier)
         
     | 
| 
      
 372 
     | 
    
         
            +
                  how, what = Elements::UnorderedList.selenium_identifier_for identifier
         
     | 
| 
      
 373 
     | 
    
         
            +
                  element = @browser.find_element(how, what)
         
     | 
| 
      
 374 
     | 
    
         
            +
                  PageObject::Elements::UnorderedList.new(element, :platform => :selenium)
         
     | 
| 
      
 375 
     | 
    
         
            +
                end
         
     | 
| 
      
 376 
     | 
    
         
            +
                
         
     | 
| 
      
 377 
     | 
    
         
            +
                #
         
     | 
| 
      
 378 
     | 
    
         
            +
                # platform method to retrieve an ordered list element
         
     | 
| 
      
 379 
     | 
    
         
            +
                # See PageObject::Accessors#ordered_list
         
     | 
| 
      
 380 
     | 
    
         
            +
                #
         
     | 
| 
      
 381 
     | 
    
         
            +
                def ordered_list_for(identifier)
         
     | 
| 
      
 382 
     | 
    
         
            +
                  how, what = Elements::OrderedList.selenium_identifier_for identifier
         
     | 
| 
      
 383 
     | 
    
         
            +
                  element = @browser.find_element(how, what)
         
     | 
| 
      
 384 
     | 
    
         
            +
                  PageObject::Elements::OrderedList.new(element, :platform => :selenium)
         
     | 
| 
      
 385 
     | 
    
         
            +
                end
         
     | 
| 
       285 
386 
     | 
    
         
             
              end
         
     | 
| 
       286 
387 
     | 
    
         
             
            end
         
     |