Skip to content

Instantly share code, notes, and snippets.

@dobbs
Created December 10, 2014 15:32
Show Gist options
  • Save dobbs/287d392b9280b89d3e4e to your computer and use it in GitHub Desktop.
Save dobbs/287d392b9280b89d3e4e to your computer and use it in GitHub Desktop.
PRY, Capybara, and Selenium for DOM REPL
require 'capybara'
Capybara.default_driver = :selenium
Capybara.javascript_driver = :selenium
Capybara.run_server = false
Capybara.app_host = 'http://localhost:3000'
class Scratch
include Capybara::DSL
def sign_in(as:, password: '5up3rSecret')
visit '/'
fill_in 'Username', with: as
fill_in 'Password', with: password
click_button 'Sign In'
end
end
@dobbs
Copy link
Author

dobbs commented Dec 10, 2014

Super lightweight way to explore your web application's DOM to discover what selectors and other capybara incantations will work best for your tests.

$ gem install pry
$ pry
[1] pry(main)> load 'scratch.rb'
[2] pry(main)> c = Scratch.new
[3] pry(main)> c.visit '/dashboard'
[4] pry(main)> c.all '.expandable'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment