module PageObject::Platforms::Watir
Public Class Methods
browser_for(root)
click to toggle source
# File lib/page-object/platforms/watir.rb, line 15 def self.browser_for root return watir_browser(root) if watir?(root) return selenium_browser(root) if selenium?(root) nil end
browser_root_for(browser)
click to toggle source
# File lib/page-object/platforms/watir.rb, line 25 def self.browser_root_for browser browser.element end
create_page_object(browser)
click to toggle source
# File lib/page-object/platforms/watir.rb, line 5 def self.create_page_object(browser) browser = selenium_browser(browser) unless watir?(browser) return Watir::PageObject.new(browser) end
is_for?(browser)
click to toggle source
# File lib/page-object/platforms/watir.rb, line 10 def self.is_for?(browser) require 'watir' watir?(browser) || selenium?(browser) end
root_element_for(root)
click to toggle source
# File lib/page-object/platforms/watir.rb, line 21 def self.root_element_for root Elements::Element.new(root) if is_for?(root) end
Private Class Methods
selenium?(browser)
click to toggle source
# File lib/page-object/platforms/watir.rb, line 45 def self.selenium?(browser) browser.is_a?(::Selenium::WebDriver::Driver) || browser.is_a?(::Selenium::WebDriver::Element) end
selenium_browser(root)
click to toggle source
# File lib/page-object/platforms/watir.rb, line 36 def self.selenium_browser(root) return ::Watir::Browser.new(root) if root.is_a?(::Selenium::WebDriver::Driver) ::Watir::Browser.new(Selenium::WebDriver::Driver.new(root.send(:bridge))) end
watir?(browser)
click to toggle source
# File lib/page-object/platforms/watir.rb, line 41 def self.watir?(browser) browser.is_a?(::Watir::Browser) || browser.is_a?(::Watir::HTMLElement) end
watir_browser(root)
click to toggle source
# File lib/page-object/platforms/watir.rb, line 31 def self.watir_browser(root) return root if root.is_a?(::Watir::Browser) root.browser end