Sha256: 64b478f585e298862de6ab1343bf5732ec2599abf71ab2d017050e97fd192173

Contents?: true

Size: 1.21 KB

Versions: 1

Compression:

Stored size: 1.21 KB

Contents

module PageObject
  module Elements

    #
    # Contains functionality that is common across all elements.
    #
    class Element
      
      def initialize(element, platform)
        @element = element
        include_platform_for platform
      end
      
      def self.identifier_for identifier, find_by, find_by_mapping
        how, what = identifier.keys.first, identifier.values.first
        return how => what if find_by.include? how
        return find_by_mapping[how] => what if find_by_mapping[how]
        return nil => what
      end
      
      protected

      def self.watir_finders
        [:class, :id, :index, :name, :xpath]
      end
      
      def self.watir_mapping
        {}
      end
      
      def self.selenium_finders
        [:class, :id, :name, :xpath]
      end
      
      def self.selenium_mapping
        {}
      end
      
      private
      
      def include_platform_for platform
        if platform[:platform] == :watir
          require 'page-object/watir_element'
          self.class.send :include, PageObject::WatirElement
        else
          require 'page-object/selenium_element'
          self.class.send :include, PageObject::SeleniumElement
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
page-object-0.0.1 lib/page-object/elements/element.rb