Skip to content

Instantly share code, notes, and snippets.

@peterkappus
Last active January 10, 2021 11:52
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save peterkappus/2495100 to your computer and use it in GitHub Desktop.
Save peterkappus/2495100 to your computer and use it in GitHub Desktop.
Quick start for using Capybara in IRB with Chromedriver
# copy and paste this into your terminal to start an IRB session and use Capybara's DSL to write tests interactively
# Thanks to Tom Clements
# http://tom-clements.com/blog/2012/02/25/capybara-on-the-command-line-live-browser-testing-from-irb/
# I prefer using chrome...
# First you need to install the chromedriver https://sites.google.com/a/chromium.org/chromedriver/downloads
# Unzip, and move the executable somewhere in your path...
# e.g.
mv ~/Downloads/chromedriver /usr/local/bin
irb
require 'capybara/dsl'
include Capybara::DSL
#register the chrome driver
Capybara.register_driver :chrome do |app|
Capybara::Selenium::Driver.new(app, :browser => :chrome)
end
Capybara.default_driver = :chrome
visit "http://www.google.com" #etc...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment