spec/implementation.rb in watir-webdriver-0.6.2 vs spec/implementation.rb in watir-webdriver-0.6.3

- old
+ new

@@ -9,11 +9,11 @@ set_webdriver set_browser_args set_guard_proc add_html_routes - WatirSpec.always_use_server = mobile? || ie? || safari? || remote? + WatirSpec.always_use_server = mobile? || ie? || safari? || phantomjs? || remote? end private def set_webdriver @@ -45,45 +45,59 @@ def mobile? [:android, :iphone].include? browser end def ie? - [:ie, :internet_explorer].include? browser + [:internet_explorer].include? browser end def safari? browser == :safari end + def phantomjs? + browser == :phantomjs + end + def remote? browser == :remote end def set_guard_proc matching_browser = remote? ? remote_browser : browser + browser_instance = WatirSpec.new_browser + browser_version = browser_instance.driver.capabilities.version + matching_browser_with_version = "#{matching_browser}#{browser_version}".to_sym matching_guards = [ :webdriver, # guard only applies to webdriver matching_browser, # guard only applies to this browser - [:webdriver, matching_browser] # guard only applies to this browser on webdriver + matching_browser_with_version, # guard only applies to this browser with specific version + [:webdriver, matching_browser], # guard only applies to this browser on webdriver + [:webdriver, matching_browser_with_version] # guard only applies to this browser with specific version on webdriver ] if native_events? # guard only applies to this browser on webdriver with native events enabled matching_guards << [:webdriver, matching_browser, :native_events] + matching_guards << [:webdriver, matching_browser_with_version, :native_events] else # guard only applies to this browser on webdriver with native events disabled matching_guards << [:webdriver, matching_browser, :synthesized_events] + matching_guards << [:webdriver, matching_browser_with_version, :synthesized_events] end if !Selenium::WebDriver::Platform.linux? || ENV['DESKTOP_SESSION'] # some specs (i.e. Window#maximize) needs a window manager on linux matching_guards << [:webdriver, matching_browser, :window_manager] + matching_guards << [:webdriver, matching_browser_with_version, :window_manager] end @imp.guard_proc = lambda { |args| args.any? { |arg| matching_guards.include?(arg) } } + ensure + browser_instance.close if browser_instance end def firefox_args profile = Selenium::WebDriver::Firefox::Profile.new profile.native_events = native_events? @@ -126,11 +140,11 @@ def browser @browser ||= (ENV['WATIR_WEBDRIVER_BROWSER'] || :firefox).to_sym end def remote_browser - remote_browser = @imp.browser_class.new(*@imp.browser_args) + remote_browser = WatirSpec.new_browser remote_browser.browser.name ensure remote_browser.close end @@ -143,10 +157,10 @@ native_events_by_default? end end def native_events_by_default? - Selenium::WebDriver::Platform.windows? && [:firefox, :ie].include?(browser) + Selenium::WebDriver::Platform.windows? && [:firefox, :internet_explorer].include?(browser) end class SelectorListener < Selenium::WebDriver::Support::AbstractEventListener def initialize @counts = Hash.new(0)