lib/page-object/loads_platform.rb
#
# Determines which platform the Page Object should use based upon browser
#
# @example
#  platform =  load_platform(watir_webdriver_browser, PageObject.Adapters.list).send(:new, watir_webdriver_browser)
# 
# @param [Object] A browser driver that has a supported adapter
# @param [adapters] a list of adapters that are currently supported
# @returns [PageObject] 
#
Determines which platform the Page Object should use based upon browser
Determines which platform the Page Object should use based upon browser
def adapter_for element_or_browser, adapters
      adapter = adapters.values.find { |adapter|
        adapter.is_for?(element_or_browser)
      }
      unless adapter
        message = "Unable to pick a platform for the provided browser or element: #{element_or_browser.inspect}."
        message += "\nnil was passed to the PageObject constructor instead of a valid browser or element object." if element_or_browser.nil?
        raise message
      end
      adapter
    end
def adapter_for element_or_browser , adapters adapter = adapters . values . find { | adapter | adapter . is_for? ( element_or_browser ) } unless adapter message = "Unable to pick a platform for the provided browser or element: #{element_or_browser.inspect}." message += "\nnil was passed to the PageObject constructor instead of a valid browser or element object." if element_or_browser . nil? raise message end adapter end
Determines which platform the Page Object should use based upon browser
Determines which platform the Page Object should use based upon browser
None
element_or_browser
<not_specific>
adapters
<not_specific>
<not_specific>
a list of adapters that are currently supported
a list of adapters that are currently supported
example
platform = load_platform(watir_webdriver_browser, PageObject.Adapters.list).send(:new, watir_webdriver_browser)
platform = load_platform ( watir_webdriver_browser PageObject . Adapters . list ) . send ( : new watir_webdriver_browser )