Merge pull request #7901 from tchak/update-webdrivers

chore(webdriver): update
This commit is contained in:
Paul Chavard 2022-10-12 13:37:49 +02:00 committed by GitHub
commit 8eb42baba5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 36 additions and 24 deletions

View file

@ -104,7 +104,7 @@ group :test do
gem 'shoulda-matchers', require: false
gem 'timecop'
gem 'vcr'
gem 'webdrivers', '~> 4.0'
gem 'webdrivers'
gem 'webmock'
end

View file

@ -162,7 +162,7 @@ GEM
rubyzip (>= 1.3.0, < 3)
charlock_holmes (0.7.7)
chartkick (4.1.3)
childprocess (3.0.0)
childprocess (4.1.0)
choice (0.2.0)
chunky_png (1.4.0)
clamav-client (3.2.0)
@ -633,7 +633,7 @@ GEM
ruby-vips (2.1.4)
ffi (~> 1.12)
ruby2_keywords (0.0.5)
rubyzip (2.3.0)
rubyzip (2.3.2)
saml_idp (0.14.0)
activesupport (>= 5.2)
builder (>= 3.0)
@ -660,9 +660,11 @@ GEM
scss_lint (0.59.0)
sass (~> 3.5, >= 3.5.5)
selectize-rails (0.12.6)
selenium-webdriver (3.142.7)
childprocess (>= 0.5, < 4.0)
rubyzip (>= 1.2.2)
selenium-webdriver (4.5.0)
childprocess (>= 0.5, < 5.0)
rexml (~> 3.2, >= 3.2.5)
rubyzip (>= 1.2.2, < 3.0)
websocket (~> 1.0)
sentry-delayed_job (4.8.1)
delayed_job (>= 4.0)
sentry-ruby-core (~> 4.8.1)
@ -766,10 +768,10 @@ GEM
activemodel (>= 6.0.0)
bindex (>= 0.4.0)
railties (>= 6.0.0)
webdrivers (4.5.0)
webdrivers (5.2.0)
nokogiri (~> 1.6)
rubyzip (>= 1.3.0)
selenium-webdriver (>= 3.0, < 4.0)
selenium-webdriver (~> 4.0)
webfinger (1.2.0)
activesupport
httpclient (>= 2.4)
@ -777,6 +779,7 @@ GEM
addressable (>= 2.3.6)
crack (>= 0.3.2)
hashdiff (>= 0.4.0, < 2.0.0)
websocket (1.2.9)
websocket-driver (0.7.5)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.5)
@ -923,7 +926,7 @@ DEPENDENCIES
vite_rails
warden
web-console
webdrivers (~> 4.0)
webdrivers
webmock
zipline
zxcvbn-ruby

View file

@ -4,18 +4,9 @@ require 'capybara/email/rspec'
require 'selenium/webdriver'
Capybara.register_driver :chrome do |app|
Capybara::Selenium::Driver.new(app, browser: :chrome)
end
Capybara.register_driver :headless_chrome do |app|
options = Selenium::WebDriver::Chrome::Options.new
options.add_argument('--no-sandbox') unless ENV['SANDBOX']
options.add_argument('--headless') unless ENV['NO_HEADLESS']
options.add_argument('--window-size=1440,900')
capabilities = Selenium::WebDriver::Remote::Capabilities.chrome(
chromeOptions: { args: ['disable-dev-shm-usage', 'disable-software-rasterizer', 'mute-audio', 'window-size=1440,900'] }
)
options.add_argument('--mute-audio')
download_path = Capybara.save_path
# Chromedriver 77 requires setting this for headless mode on linux
@ -23,10 +14,28 @@ Capybara.register_driver :headless_chrome do |app|
options.add_preference('download.default_directory', download_path)
options.add_preference(:download, default_directory: download_path)
Capybara::Selenium::Driver.new(app,
browser: :chrome,
desired_capabilities: capabilities,
options: options).tap do |driver|
Capybara::Selenium::Driver.new(app, browser: :chrome, options: options).tap do |driver|
# Set download dir for Chrome < 77
driver.browser.download_path = download_path
end
end
Capybara.register_driver :headless_chrome do |app|
options = Selenium::WebDriver::Chrome::Options.new
options.add_argument('--no-sandbox') unless ENV['SANDBOX']
options.add_argument('--headless')
options.add_argument('--window-size=1440,900')
options.add_argument('--disable-dev-shm-usage')
options.add_argument('--disable-software-rasterizer')
options.add_argument('--mute-audio')
download_path = Capybara.save_path
# Chromedriver 77 requires setting this for headless mode on linux
# Different versions of Chrome/selenium-webdriver require setting differently - just set them all
options.add_preference('download.default_directory', download_path)
options.add_preference(:download, default_directory: download_path)
Capybara::Selenium::Driver.new(app, browser: :chrome, options: options).tap do |driver|
# Set download dir for Chrome < 77
driver.browser.download_path = download_path
end
@ -53,7 +62,7 @@ RSpec.configure do |config|
end
config.before(:each, type: :system, js: true) do
driven_by :headless_chrome
driven_by ENV['NO_HEADLESS'] ? :chrome : :headless_chrome
end
# Set the user preferred language before Javascript system specs.