Skip to main content

Debugging

debug(binding = nil)​

Pauses the test and opens DevTools for the current page in a new Chrome window, where you can inspect the content. If you pass binding, a pry (if loaded) or irb console is opened where you can further experiment with the test.

it "does something useful" do
visit root_path

fill_in "field", with: "value"
page.driver.debug(binding)

expect(page).to have_content("value")
end

Pausing without DevTools​

Run the test with headless: false and put a Ruby breakpoint where you want it to stop:

binding.irb

Headful mode​

Run the browser with UI and slow down every command to see what's going on:

Capybara::Cuprite::Driver.new(app, headless: false, slowmo: 0.5)

Logging​

Set CUPRITE_DEBUG to print all CDP messages exchanged with the browser:

CUPRITE_DEBUG=true bundle exec rspec

Or pass a logger object responding to puts:

Capybara::Cuprite::Driver.new(app, logger: StringIO.new)