capybara icon indicating copy to clipboard operation
capybara copied to clipboard

Capybara Chrome resets developer tools between tests

Open rbclark opened this issue 11 months ago • 0 comments

Meta

Capybara Version: 3.40.0

Driver Information (and browser if relevant): selenium-webdriver (4.18.1), Chrome (122)

Expected Behavior

I have created a custom Capybara driver that I use for debugging. The definition looks as follows:

Capybara.register_driver :chrome_with_network_tab do |app|
  options = Selenium::WebDriver::Chrome::Options.new(args: %w[auto-open-devtools-for-tabs])
  options.add_preference(
    "devtools",
    "preferences" => {
      "currentDockState" => '"right"',
      "panel-selectedTab" => '"network"'
    }
  )

  Capybara::Selenium::Driver.new(
    app,
    browser: :chrome,
    options: options
  )
end

When running this I expect that every test will be run with the devtools open to the network tab.

Actual Behavior

Instead of running every test with the devtools open, it only runs the first test in the series with devtools open. It is then closed for any subsequent tests. I've found that removing the following 2 lines from the Chrome driver has caused the devtools to be maintained between tests, which has at least helped me in the short term:

https://github.com/teamcapybara/capybara/blob/c0cbf4024c1abd48b0c22c2930e7b05af58ab284/lib/capybara/selenium/driver_specializations/chrome_driver.rb#L40-L41

Steps to reproduce

This can be reproduced by dropping this Capybara driver into any project that utilizes system tests.

rbclark avatar Mar 14 '24 16:03 rbclark