lib/howitzer/capybara_helpers.rb in howitzer-2.0.3 vs lib/howitzer/capybara_helpers.rb in howitzer-2.1.0

- old
+ new

@@ -3,16 +3,32 @@ module Howitzer # This module holds capybara helpers methods module CapybaraHelpers CHECK_YOUR_SETTINGS_MSG = 'Please check your settings'.freeze #:nodoc: + HOWITZER_KNOWN_BROWSERS = [ #:nodoc: + CLOUD_BROWSERS = [ + SAUCE = :sauce, + TESTINGBOT = :testingbot, + BROWSERSTACK = :browserstack, + CROSSBROWSERTESTING = :crossbrowsertesting + ].freeze, + LOCAL_BROWSERS = [ + HEADLESS_CHROME = :headless_chrome, + PHANTOMJS = :phantomjs, + POLTERGEIST = :poltergeist, + SELENIUM = :selenium, + SELENIUM_GRID = :selenium_grid, + WEBKIT = :webkit + ].freeze + ].freeze # @return [Boolean] true if current driver related with SauceLab, # Testingbot or Browserstack cloud service def cloud_driver? - %i[sauce testingbot browserstack].include?(Howitzer.driver.to_sym) + CLOUD_BROWSERS.include?(Howitzer.driver.to_sym) end # @return [Boolean] whether or not current browser is # Internet Explorer. # @raise [CloudBrowserNotSpecifiedError] if cloud driver and missing browser name @@ -33,11 +49,11 @@ # @return [Boolean] whether or not current browser is Google Chrome. # @raise [CloudBrowserNotSpecifiedError] if cloud driver and missing browser name # @raise [SelBrowserNotSpecifiedError] if selenium driver and missing browser name def chrome_browser? - browser? :chrome + browser?(:chrome) || Howitzer.driver == HEADLESS_CHROME.to_s end # @return [Boolean] whether or not current browser is Safari. # @raise [CloudBrowserNotSpecifiedError] if cloud driver and missing browser name # @raise [SelBrowserNotSpecifiedError] if selenium driver and missing browser name @@ -62,11 +78,11 @@ # @note SauceLabs is currently supported only # @param json_data [Hash] for example, (passed: true) def update_cloud_job_status(json_data = {}) case Howitzer.driver.to_sym - when :sauce then update_sauce_job_status(json_data) + when SAUCE then update_sauce_job_status(json_data) else '[NOT IMPLEMENTED]' end end @@ -100,11 +116,12 @@ # @param url [String] a remote hub url # @return [Capybara::Selenium::Driver] def cloud_driver(app, caps, url) http_client = ::Selenium::WebDriver::Remote::Http::Default.new - http_client.timeout = Howitzer.cloud_http_idle_timeout + http_client.read_timeout = Howitzer.cloud_http_idle_timeout + http_client.open_timeout = Howitzer.cloud_http_idle_timeout options = { url: url, desired_capabilities: ::Selenium::WebDriver::Remote::Capabilities.new(caps), http_client: http_client, @@ -119,11 +136,11 @@ # @note Currently SauceLabs is supported only # @raise [ArgumentError] if unknown kind def cloud_resource_path(kind) case Howitzer.driver.to_sym - when :sauce then sauce_resource_path(kind) + when SAUCE then sauce_resource_path(kind) else '[NOT IMPLEMENTED]' end end @@ -134,11 +151,11 @@ return selenium_browser?(*browser_aliases) if selenium_driver? || selenium_grid_driver? end def cloud_browser?(*browser_aliases) unless Howitzer.cloud_browser_name.nil? - return browser_aliases.include?(Howitzer.cloud_browser_name.to_s.to_sym) + return browser_aliases.include?(Howitzer.cloud_browser_name.to_s.downcase.to_sym) end raise Howitzer::CloudBrowserNotSpecifiedError, CHECK_YOUR_SETTINGS_MSG end def selenium_browser?(*browser_aliases) @@ -147,14 +164,14 @@ end raise Howitzer::SelBrowserNotSpecifiedError, CHECK_YOUR_SETTINGS_MSG end def selenium_driver? - Howitzer.driver.to_sym == :selenium + Howitzer.driver.to_sym == SELENIUM end def selenium_grid_driver? - Howitzer.driver.to_sym == :selenium_grid + Howitzer.driver.to_sym == SELENIUM_GRID end def prefix_name (Howitzer.current_rake_task || 'ALL').upcase end