Update (2019): This article was written in 2015. Consider avoiding Poltergeist and PhantomJS mentioned in this article; they have since been deprecated.
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.
Using binding.pry
will halt everything, making your browser not load anything because Rails can't respond to the request.
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:
If you're using Capybara with Rspec, you can turn this into a helper. You can then just use pause
in your tests.
When using Poltergeist (for PhantomJS support), just use its Remote Debugging feature with the inspector: true
flag.