Open devtools when running a Selenium Chrome test
The Network tab in Chrome devtools doesn't record requests unless devtools is open. This makes debugging specific issues in tests much harder. It's great being able to see which api requests were made and what payloads they returned.
You can start Chrome with devtools open though with the the chrome option --auto-open-devtools-for-tabs
.
If you are using Selenium with Chrome in a Ruby integration test, you can pass the option
opts = {
browser: :chrome,
options: Selenium::WebDriver::Chrome::Options.new(
args: %w(--auto-open-devtools-for-tabs --window-size=2400,2400)
)
}
Capybara.register_driver :chrome do |app|
Capybara::Selenium::Driver.new(app, opts)
end
Opening devtools automatically may restrict your window size enough to disrupt some of your tests in which case you can set -window-size
to a value that accomodates your website.