DRY chrome options in test

This commit is contained in:
Thomas Walpole 2017-06-15 16:25:01 -07:00
parent a02e0c94f0
commit 3f4d584e5a
1 changed files with 12 additions and 15 deletions

View File

@ -3,25 +3,22 @@ require 'spec_helper'
require 'selenium-webdriver'
require 'shared_selenium_session'
chrome_options = {
browser: :chrome,
options: ::Selenium::WebDriver::Chrome::Options.new(args: ENV['TRAVIS'] ? ['no-sandbox' ] : [])
}
if ENV['CAPYBARA_CHROME_HEADLESS']
chrome_options[:options].args << 'headless'
Selenium::WebDriver::Chrome.path='/usr/bin/google-chrome-beta' if ENV['TRAVIS']
end
Capybara.register_driver :selenium_chrome do |app|
args = ENV['TRAVIS'] ? ['no-sandbox' ] : []
if ENV['CAPYBARA_CHROME_HEADLESS']
args << 'headless'
Selenium::WebDriver::Chrome.path='/usr/bin/google-chrome-beta' if ENV['TRAVIS']
end
Capybara::Selenium::Driver.new(app, :browser => :chrome, :args => args)
Capybara::Selenium::Driver.new(app, chrome_options)
end
Capybara.register_driver :selenium_chrome_clear_storage do |app|
args = ENV['TRAVIS'] ? ['no-sandbox' ] : []
if ENV['CAPYBARA_CHROME_HEADLESS']
args << 'headless'
Selenium::WebDriver::Chrome.path='/usr/bin/google-chrome-beta' if ENV['TRAVIS']
end
Capybara::Selenium::Driver.new(app, :browser => :chrome,
:args => args,
clear_local_storage: true,
clear_session_storage: true)
Capybara::Selenium::Driver.new(app, chrome_options.merge(clear_local_storage: true, clear_session_storage: true))
end
module TestSessions