Support selenium-webdriver 4

* Use public API to add argument to the selenium driver.

  While `args` is also public API it doesn't know how to handle if no
  argument is being set yet in Selenium 4.

* Fix assertions to match return on Selenium 4
This commit is contained in:
Rafael Mendonça França 2020-12-29 01:11:25 +00:00
parent 947a9f903a
commit 03156c829d
No known key found for this signature in database
GPG Key ID: FC23B6D0F1EEE948
4 changed files with 18 additions and 13 deletions

View File

@ -10,7 +10,7 @@ gemspec
gem "rake", ">= 11.1"
gem "capybara", ">= 3.26"
gem "selenium-webdriver", ">= 3.141.592"
gem "selenium-webdriver", ">= 4.0.0.alpha7"
gem "rack-cache", "~> 1.2"
gem "sass-rails"

View File

@ -193,7 +193,7 @@ GEM
rack-test (>= 0.6.3)
regexp_parser (~> 1.5)
xpath (~> 3.2)
childprocess (3.0.0)
childprocess (4.0.0)
coffee-script (2.4.1)
coffee-script-source
execjs
@ -455,9 +455,10 @@ GEM
tilt
sdoc (2.0.3)
rdoc (>= 5.0)
selenium-webdriver (3.142.7)
childprocess (>= 0.5, < 4.0)
selenium-webdriver (4.0.0.alpha7)
childprocess (>= 0.5, < 5.0)
rubyzip (>= 1.2.2)
websocket (~> 1.0)
semantic_range (2.3.0)
sequel (5.38.0)
serverengine (2.0.7)
@ -605,7 +606,7 @@ DEPENDENCIES
rubocop-rails
sass-rails
sdoc (>= 2.0.3)
selenium-webdriver (>= 3.141.592)
selenium-webdriver (>= 4.0.0.alpha7)
sequel
sidekiq
sneakers
@ -625,4 +626,4 @@ DEPENDENCIES
websocket-client-simple!
BUNDLED WITH
2.1.4
2.2.3

View File

@ -71,14 +71,14 @@ module ActionDispatch
def set_headless_chrome_browser_options
configure do |capabilities|
capabilities.args << "--headless"
capabilities.args << "--disable-gpu" if Gem.win_platform?
capabilities.add_argument("--headless")
capabilities.add_argument("--disable-gpu") if Gem.win_platform?
end
end
def set_headless_firefox_browser_options
configure do |capabilities|
capabilities.args << "-headless"
capabilities.add_argument("-headless")
end
end
end

View File

@ -69,7 +69,8 @@ class DriverTest < ActiveSupport::TestCase
"args" => ["start-maximized"],
"mobileEmulation" => { "deviceName" => "iphone 6" },
"prefs" => { "detach" => true }
}
},
"browserName" => "chrome"
}
assert_equal expected, browser_options[:options].as_json
end
@ -88,7 +89,8 @@ class DriverTest < ActiveSupport::TestCase
"args" => ["--headless", "start-maximized"],
"mobileEmulation" => { "deviceName" => "iphone 6" },
"prefs" => { "detach" => true }
}
},
"browserName" => "chrome"
}
assert_equal expected, browser_options[:options].as_json
end
@ -105,7 +107,8 @@ class DriverTest < ActiveSupport::TestCase
"moz:firefoxOptions" => {
"args" => ["--host=127.0.0.1"],
"prefs" => { "browser.startup.homepage" => "http://www.seleniumhq.com/" }
}
},
"browserName" => "firefox"
}
assert_equal expected, browser_options[:options].as_json
end
@ -122,7 +125,8 @@ class DriverTest < ActiveSupport::TestCase
"moz:firefoxOptions" => {
"args" => ["-headless", "--host=127.0.0.1"],
"prefs" => { "browser.startup.homepage" => "http://www.seleniumhq.com/" }
}
},
"browserName" => "firefox"
}
assert_equal expected, browser_options[:options].as_json
end