Want to use the Web Inspector in Capybara/Selenium tests? The first thing you’ll probably try is to use pry-byebug to pause your tests. You’ll probably find that this doesn’t work as intended: it will halt everything, making your browser not load anything because Rails can’t respond to the request.
scenario 'visiting the home page' do visit root_path binding.pry # ✗ end
A better alternative is to use
$stdin.gets. This is what Poltergeist uses to pause execution. That method is not available in Capybara/Selenium though, so you’ll need to add it in yourself:
$stderr.write 'Press enter to continue' $stdin.gets
If you’re using Capybara with Rspec, you can turn this into a helper. You can then just use
pause in your tests.
# spec/support/pause_helpers.rb module PauseHelpers def pause $stderr.write 'Press enter to continue' $stdin.gets end end
# spec/rails_helper.rb RSpec.configure do config.include PauseHelpers, type: :feature end
When using Poltergeist (for PhantomJS support), just use its Remote Debugging feature with the
inspector: true flag.