-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
34 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,97 +1,49 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'selenium/webdriver' | ||
require 'capybara/minitest' | ||
include Capybara::Minitest::Assertions | ||
|
||
# in case firefox is needed! | ||
#Capybara.register_driver :selenium do |app| | ||
# Capybara::Selenium::Driver.new(app, :browser => :firefox) | ||
#end | ||
|
||
DEFAULT_JS_DRIVER = :headless_chrome | ||
# in case firefox is needed! | ||
# DEFAULT_JS_DRIVER = :headless_firefox | ||
|
||
Capybara.configure do |config| | ||
config.default_driver = :rack_test | ||
config.javascript_driver = DEFAULT_JS_DRIVER | ||
config.default_selector = :css | ||
config.raise_server_errors = true | ||
config.match = :prefer_exact | ||
config.match = :smart | ||
|
||
config.javascript_driver = DEFAULT_JS_DRIVER | ||
config.always_include_port = true | ||
config.default_max_wait_time = 10 | ||
# Capybara 3 changes the default server to Puma. It can be reverted to the previous default of WEBRick by specifying: | ||
config.server = :webrick | ||
config.server = :webrick # default is `:default` (which uses puma) | ||
config.disable_animation = true | ||
end | ||
|
||
Around '@security' do |scenario, block| | ||
with_forgery_protection(&block) | ||
end | ||
|
||
# monkeypatch to fix | ||
# not opened for reading (IOError) | ||
# /cucumber-1.3.20/lib/cucumber/formatter/interceptor.rb:33:in `each' | ||
# /cucumber-1.3.20/lib/cucumber/formatter/interceptor.rb:33:in `collect' | ||
# /cucumber-1.3.20/lib/cucumber/formatter/interceptor.rb:33:in `method_missing' | ||
require 'cucumber/formatter/interceptor' | ||
class Cucumber::Formatter::Interceptor::Pipe | ||
def is_a?(klass) | ||
super || klass == IO | ||
end | ||
end | ||
|
||
Capybara.register_driver :firefox do |app| | ||
Capybara::Selenium::Driver.new(app, browser: :firefox) | ||
end | ||
|
||
Capybara.register_driver :headless_firefox do |app| | ||
options = Selenium::WebDriver::Firefox::Options.new | ||
|
||
options.add_argument('-headless') | ||
options.add_argument('--window-size=1280,2048') | ||
|
||
driver = Capybara::Selenium::Driver.new(app, browser: :firefox, options: options) | ||
|
||
driver | ||
end | ||
|
||
Capybara.register_driver :firefox do |app| | ||
options = Selenium::WebDriver::Firefox::Options.new | ||
|
||
options.add_argument('--window-size=1280,2048') | ||
|
||
driver = Capybara::Selenium::Driver.new(app, browser: :firefox, options: options) | ||
|
||
driver | ||
end | ||
BASE_DRIVER_OPTIONS = { | ||
args: [ | ||
# When width < 1200px, vertical navigation overlaps the page's main content and that will make | ||
# some cucumbers fail | ||
'--window-size=1200,2048', | ||
'--disable-search-engine-choice-screen' | ||
] | ||
}.freeze | ||
|
||
Capybara.register_driver :chrome do |app| | ||
options = Selenium::WebDriver::Chrome::Options.new | ||
options.add_argument('--window-size=1280,2048') | ||
options.add_argument('--disable-search-engine-choice-screen') | ||
options = Selenium::WebDriver::Options.chrome(**BASE_DRIVER_OPTIONS) | ||
Capybara::Selenium::Driver.new(app, browser: :chrome, options: options) | ||
end | ||
|
||
Capybara.register_driver :headless_chrome do |app| | ||
options = Selenium::WebDriver::Options.chrome( | ||
logging_prefs: { performance: 'ALL', browser: 'ALL' }, | ||
perf_logging_prefs: { enableNetwork: true } | ||
) | ||
options = Selenium::WebDriver::Options.chrome(**BASE_DRIVER_OPTIONS) | ||
|
||
options.add_argument('--headless=new') | ||
options.add_argument('--no-sandbox') | ||
options.add_argument('--disable-popup-blocking') | ||
options.add_argument('--window-size=1280,2048') | ||
options.add_argument('--host-resolver-rules=MAP * ~NOTFOUND , EXCLUDE *localhost*') | ||
options.add_argument('--disable-search-engine-choice-screen') | ||
options.add_argument('--disable-gpu') | ||
|
||
options.add_preference(:browser, set_download_behavior: { behavior: 'allow' }) | ||
options.logging_prefs = { performance: 'ALL', browser: 'ALL' } | ||
options.add_option(:perf_logging_prefs, enableNetwork: true) | ||
|
||
timeout = 120 # default 60 | ||
client = Selenium::WebDriver::Remote::Http::Default.new(open_timeout: timeout, read_timeout: timeout) | ||
options.add_preference(:browser, set_download_behavior: { behavior: 'allow' }) | ||
|
||
Capybara::Selenium::Driver.new(app, browser: :chrome, options: options, http_client: client) | ||
Capybara::Selenium::Driver.new(app, browser: :chrome, options: options, timeout: 120) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters