diff options
author | Stan Hu <stanhu@gmail.com> | 2017-11-30 23:00:18 +0000 |
---|---|---|
committer | Stan Hu <stanhu@gmail.com> | 2017-11-30 23:00:18 +0000 |
commit | 3b6fba728fdef4b1824dcfc33539e696e4f17cf5 (patch) | |
tree | 6a175861bb34351ab433c94c3bbb725a5637fc08 | |
parent | 4ce2b9b083caabf2f90633177894ea4899aee56d (diff) | |
parent | b755c883bcc47382e1115d286062edb25392e25d (diff) | |
download | gitlab-ce-3b6fba728fdef4b1824dcfc33539e696e4f17cf5.tar.gz |
Merge branch 'clean-capybara-config' into 'master'
Clean up Capybara configuration
Closes #40599
See merge request gitlab-org/gitlab-ce!15644
-rw-r--r-- | features/support/capybara.rb | 36 | ||||
-rw-r--r-- | spec/support/capybara.rb | 36 |
2 files changed, 56 insertions, 16 deletions
diff --git a/features/support/capybara.rb b/features/support/capybara.rb index 3c4db8b9601..5a77b859113 100644 --- a/features/support/capybara.rb +++ b/features/support/capybara.rb @@ -3,21 +3,41 @@ require 'capybara-screenshot/spinach' # Give CI some extra time timeout = (ENV['CI'] || ENV['CI_SERVER']) ? 60 : 30 -Capybara.javascript_driver = :chrome Capybara.register_driver :chrome do |app| - extra_args = [] - extra_args << 'headless' unless ENV['CHROME_HEADLESS'] =~ /^(false|no|0)$/i - capabilities = Selenium::WebDriver::Remote::Capabilities.chrome( - chromeOptions: { - 'args' => %w[no-sandbox disable-gpu --window-size=1240,1400] + extra_args + # This enables access to logs with `page.driver.manage.get_log(:browser)` + loggingPrefs: { + browser: "ALL", + client: "ALL", + driver: "ALL", + server: "ALL" } ) - Capybara::Selenium::Driver - .new(app, browser: :chrome, desired_capabilities: capabilities) + options = Selenium::WebDriver::Chrome::Options.new + options.add_argument("window-size=1240,1400") + + # Chrome won't work properly in a Docker container in sandbox mode + options.add_argument("no-sandbox") + + # Run headless by default unless CHROME_HEADLESS specified + unless ENV['CHROME_HEADLESS'] =~ /^(false|no|0)$/i + options.add_argument("headless") + + # Chrome documentation says this flag is needed for now + # https://developers.google.com/web/updates/2017/04/headless-chrome#cli + options.add_argument("disable-gpu") + end + + Capybara::Selenium::Driver.new( + app, + browser: :chrome, + desired_capabilities: capabilities, + options: options + ) end +Capybara.javascript_driver = :chrome Capybara.default_max_wait_time = timeout Capybara.ignore_hidden_elements = false diff --git a/spec/support/capybara.rb b/spec/support/capybara.rb index 9f672bc92fc..935b170a0f6 100644 --- a/spec/support/capybara.rb +++ b/spec/support/capybara.rb @@ -7,21 +7,41 @@ require 'selenium-webdriver' # Give CI some extra time timeout = (ENV['CI'] || ENV['CI_SERVER']) ? 60 : 30 -Capybara.javascript_driver = :chrome Capybara.register_driver :chrome do |app| - extra_args = [] - extra_args << 'headless' unless ENV['CHROME_HEADLESS'] =~ /^(false|no|0)$/i - capabilities = Selenium::WebDriver::Remote::Capabilities.chrome( - chromeOptions: { - 'args' => %w[no-sandbox disable-gpu --window-size=1240,1400] + extra_args + # This enables access to logs with `page.driver.manage.get_log(:browser)` + loggingPrefs: { + browser: "ALL", + client: "ALL", + driver: "ALL", + server: "ALL" } ) - Capybara::Selenium::Driver - .new(app, browser: :chrome, desired_capabilities: capabilities) + options = Selenium::WebDriver::Chrome::Options.new + options.add_argument("window-size=1240,1400") + + # Chrome won't work properly in a Docker container in sandbox mode + options.add_argument("no-sandbox") + + # Run headless by default unless CHROME_HEADLESS specified + unless ENV['CHROME_HEADLESS'] =~ /^(false|no|0)$/i + options.add_argument("headless") + + # Chrome documentation says this flag is needed for now + # https://developers.google.com/web/updates/2017/04/headless-chrome#cli + options.add_argument("disable-gpu") + end + + Capybara::Selenium::Driver.new( + app, + browser: :chrome, + desired_capabilities: capabilities, + options: options + ) end +Capybara.javascript_driver = :chrome Capybara.default_max_wait_time = timeout Capybara.ignore_hidden_elements = true |