Commit 3b6fba72 authored by Stan Hu's avatar Stan Hu

Merge branch 'clean-capybara-config' into 'master'

Clean up Capybara configuration

Closes #40599

See merge request gitlab-org/gitlab-ce!15644
parents 4ce2b9b0 b755c883
...@@ -3,21 +3,41 @@ require 'capybara-screenshot/spinach' ...@@ -3,21 +3,41 @@ require 'capybara-screenshot/spinach'
# Give CI some extra time # Give CI some extra time
timeout = (ENV['CI'] || ENV['CI_SERVER']) ? 60 : 30 timeout = (ENV['CI'] || ENV['CI_SERVER']) ? 60 : 30
Capybara.javascript_driver = :chrome
Capybara.register_driver :chrome do |app| 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( capabilities = Selenium::WebDriver::Remote::Capabilities.chrome(
chromeOptions: { # This enables access to logs with `page.driver.manage.get_log(:browser)`
'args' => %w[no-sandbox disable-gpu --window-size=1240,1400] + extra_args loggingPrefs: {
browser: "ALL",
client: "ALL",
driver: "ALL",
server: "ALL"
} }
) )
Capybara::Selenium::Driver options = Selenium::WebDriver::Chrome::Options.new
.new(app, browser: :chrome, desired_capabilities: capabilities) 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 end
Capybara.javascript_driver = :chrome
Capybara.default_max_wait_time = timeout Capybara.default_max_wait_time = timeout
Capybara.ignore_hidden_elements = false Capybara.ignore_hidden_elements = false
......
...@@ -7,21 +7,41 @@ require 'selenium-webdriver' ...@@ -7,21 +7,41 @@ require 'selenium-webdriver'
# Give CI some extra time # Give CI some extra time
timeout = (ENV['CI'] || ENV['CI_SERVER']) ? 60 : 30 timeout = (ENV['CI'] || ENV['CI_SERVER']) ? 60 : 30
Capybara.javascript_driver = :chrome
Capybara.register_driver :chrome do |app| 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( capabilities = Selenium::WebDriver::Remote::Capabilities.chrome(
chromeOptions: { # This enables access to logs with `page.driver.manage.get_log(:browser)`
'args' => %w[no-sandbox disable-gpu --window-size=1240,1400] + extra_args loggingPrefs: {
browser: "ALL",
client: "ALL",
driver: "ALL",
server: "ALL"
} }
) )
Capybara::Selenium::Driver options = Selenium::WebDriver::Chrome::Options.new
.new(app, browser: :chrome, desired_capabilities: capabilities) 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 end
Capybara.javascript_driver = :chrome
Capybara.default_max_wait_time = timeout Capybara.default_max_wait_time = timeout
Capybara.ignore_hidden_elements = true Capybara.ignore_hidden_elements = true
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment