lib/howitzer/capybara_helpers.rb in howitzer-2.2.0 vs lib/howitzer/capybara_helpers.rb in howitzer-2.3.0
- old
+ new
@@ -1,26 +1,46 @@
require 'rest-client'
require 'howitzer/exceptions'
+# There is an issue with supporting Ruby 3 by Selenium Webdriver 3.x version
+# https://github.com/SeleniumHQ/selenium/issues/9001
+# Migration to Selenium Webdriver 4 is planned when it will be released without alfa, beta stages.
+if Gem::Requirement.new('>=3').satisfied_by?(Gem::Version.new(RUBY_VERSION)) ||
+ Gem::Requirement.new(['>=3', '<4']).satisfied_by?(Gem::Version.new(Selenium::WebDriver::VERSION))
+ module Selenium
+ module WebDriver
+ module Remote
+ class Bridge # rubocop:disable Style/Documentation
+ class << self
+ alias original_handshake handshake
+
+ def handshake(opts = {})
+ original_handshake(**opts)
+ end
+ end
+ end
+ end
+ end
+ end
+end
+
module Howitzer
# This module holds capybara helpers methods
module CapybaraHelpers
- CHECK_YOUR_SETTINGS_MSG = 'Please check your settings'.freeze #:nodoc:
- HOWITZER_KNOWN_BROWSERS = [ #:nodoc:
+ 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,
HEADLESS_FIREFOX = :headless_firefox,
- POLTERGEIST = :poltergeist,
SELENIUM = :selenium,
- SELENIUM_GRID = :selenium_grid,
- WEBKIT = :webkit
+ SELENIUM_GRID = :selenium_grid
].freeze
].freeze
# @return [Boolean] true if current driver related with SauceLab,
# Testingbot or Browserstack cloud service
@@ -125,11 +145,11 @@
url: url,
desired_capabilities: ::Selenium::WebDriver::Remote::Capabilities.new(caps),
http_client: http_client,
browser: :remote
}
- driver = Capybara::Selenium::Driver.new(app, options)
+ driver = Capybara::Selenium::Driver.new(app, **options)
driver.browser.file_detector = remote_file_detector
driver
end
# @return [String] path to cloud resources (logs, videos, etc.)
@@ -197,10 +217,10 @@
path = "/rest/#{Howitzer.cloud_auth_login}/jobs/#{session_id}/results/#{name}"
"#{host}#{path}"
end
def update_sauce_job_status(json_data = {})
- host = "http://#{Howitzer.cloud_auth_login}:#{Howitzer.cloud_auth_pass}@saucelabs.com"
+ host = "https://#{Howitzer.cloud_auth_login}:#{Howitzer.cloud_auth_pass}@saucelabs.com"
path = "/rest/v1/#{Howitzer.cloud_auth_login}/jobs/#{session_id}"
url = "#{host}#{path}"
::RestClient.put url, json_data.to_json, content_type: :json, accept: :json
end