Skip to content

Commit 90cf668

Browse files
Use core cuprite definitions
1 parent 8ca891f commit 90cf668

1 file changed

Lines changed: 31 additions & 4 deletions

File tree

test/test_helpers/cuprite_setup.rb

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,40 @@
66
# Then, we need to register our driver to be able to use it later
77
# with #driven_by method.
88
Capybara.register_driver(:primer_cuprite) do |app|
9-
Capybara::Cuprite::Driver.new(
10-
app,
9+
options = {
10+
process_timeout: 20,
11+
timeout: 10,
12+
# In case the timeout is not enough, this option can be activated:
13+
# pending_connection_errors: false,
1114
inspector: true,
1215
# Allow running Chrome in a headful mode by setting HEADLESS env
1316
# var to a falsey value
14-
headless: !ENV["HEADLESS"].in?(%w[n 0 no false])
15-
)
17+
headless: !ENV["HEADLESS"].in?(%w[n 0 no false]),
18+
# workaround for compatibility issues with browserless docker image and ferrum
19+
# see https://github.com/rubycdp/ferrum/issues/540
20+
flatten: false
21+
}
22+
23+
browser_options = {
24+
"disable-dev-shm-usage": nil,
25+
"disable-gpu": nil,
26+
"disable-popup-blocking": nil,
27+
"no-sandbox": nil,
28+
"disable-smooth-scrolling": true,
29+
# Disable timers being throttled in background pages/tabs. Useful for
30+
# parallel test runs.
31+
"disable-background-timer-throttling": nil,
32+
# Normally, Chrome will treat a 'foreground' tab instead as backgrounded
33+
# if the surrounding window is occluded (aka visually covered) by another
34+
# window. This flag disables that. Useful for parallel test runs.
35+
"disable-backgrounding-occluded-windows": nil,
36+
# This disables non-foreground tabs from getting a lower process priority.
37+
# Useful for parallel test runs.
38+
"disable-renderer-backgrounding": nil
39+
}
40+
41+
driver_options = options.merge(browser_options:)
42+
Capybara::Cuprite::Driver.new(app, **driver_options)
1643
end
1744

1845
# Configure Capybara to use :cuprite driver by default

0 commit comments

Comments
 (0)