Merge pull request #3828 from eelcodevlieger/webdrivers

Webdrivers
This commit is contained in:
Pau Pérez Fabregat
2019-05-27 11:20:04 +02:00
committed by GitHub
3 changed files with 16 additions and 20 deletions

View File

@@ -127,12 +127,12 @@ group :test, :development do
gem 'letter_opener', '>= 1.4.1'
gem 'timecop'
gem 'selenium-webdriver'
gem 'chromedriver-helper'
gem 'rspec-retry'
gem 'json_spec', '~> 1.1.4'
gem 'unicorn-rails'
gem 'atomic'
gem 'knapsack'
gem 'webdrivers', '3.8.1'
end
group :test do

View File

@@ -179,8 +179,6 @@ GEM
tilt
angularjs-file-upload-rails (2.4.1)
angularjs-rails (1.5.5)
archive-zip (0.7.0)
io-like (~> 0.3.0)
arel (3.0.3)
ast (2.4.0)
atomic (1.1.101)
@@ -211,9 +209,6 @@ GEM
xpath (>= 2.0, < 4.0)
childprocess (0.9.0)
ffi (~> 1.0, >= 1.0.11)
chromedriver-helper (1.1.0)
archive-zip (~> 0.7.0)
nokogiri (~> 1.6)
chronic (0.10.2)
chunky_png (1.3.10)
climate_control (0.2.0)
@@ -501,7 +496,6 @@ GEM
i18n (>= 0.6.6)
immigrant (0.3.6)
activerecord (>= 3.0)
io-like (0.3.0)
ipaddress (0.8.3)
jaro_winkler (1.5.1)
journey (1.0.4)
@@ -769,6 +763,10 @@ GEM
railties (>= 3.0)
warden (1.2.7)
rack (>= 1.0)
webdrivers (3.8.1)
nokogiri (~> 1.6)
rubyzip (~> 1.0)
selenium-webdriver (~> 3.0)
webmock (3.5.1)
addressable (>= 2.3.6)
crack (>= 0.3.2)
@@ -799,7 +797,6 @@ DEPENDENCIES
bugsnag
byebug (~> 9.0.0)
capybara (>= 2.15.4)
chromedriver-helper
coffee-rails (~> 3.2.1)
combine_pdf
compass-rails
@@ -886,6 +883,7 @@ DEPENDENCIES
unicorn
unicorn-rails
web!
webdrivers (= 3.8.1)
webmock
whenever
wicked_pdf

View File

@@ -22,10 +22,16 @@ require 'database_cleaner'
require 'rspec/retry'
require 'paper_trail/frameworks/rspec'
require 'webdrivers'
# Allow connections to phantomjs/selenium whilst raising errors
# when connecting to external sites
require 'webmock/rspec'
WebMock.disable_net_connect!(:allow_localhost => true)
WebMock.enable!
WebMock.disable_net_connect!({
allow_localhost: true,
allow: 'chromedriver.storage.googleapis.com'
})
# Requires supporting ruby files with custom matchers and macros, etc,
# in spec/support/ and its subdirectories.
@@ -46,17 +52,9 @@ Capybara.register_driver :chrome do |app|
options = Selenium::WebDriver::Chrome::Options.new(
args: %w[headless disable-gpu no-sandbox window-size=1280,768]
)
driver = Capybara::Selenium::Driver.new(app, browser: :chrome, options: options)
### Allow file downloads in headless chrome
### https://bugs.chromium.org/p/chromium/issues/detail?id=696481#c89
bridge = driver.browser.send(:bridge)
path = '/session/:session_id/chromium/send_command'
path[':session_id'] = bridge.session_id
bridge.http.call(:post, path, cmd: 'Page.setDownloadBehavior',
params: { behavior: 'allow', downloadPath: DownloadsHelper.path.to_s })
driver
Capybara::Selenium::Driver
.new(app, browser: :chrome, options: options)
.tap { |driver| driver.browser.download_path = DownloadsHelper.path.to_s }
end
Capybara.default_max_wait_time = 30