|
6 | 6 | # Then, we need to register our driver to be able to use it later |
7 | 7 | # with #driven_by method. |
8 | 8 | 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, |
11 | 14 | inspector: true, |
12 | 15 | # Allow running Chrome in a headful mode by setting HEADLESS env |
13 | 16 | # 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) |
16 | 43 | end |
17 | 44 |
|
18 | 45 | # Configure Capybara to use :cuprite driver by default |
|
0 commit comments