Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Capybara Example
require 'capybara'
class CapybaraHelper
attr_accessor :session
def initialize
# Register Chrome driver
# You might need to install Chrome Driver to make it run (e.g 'brew install chromedriver')
Capybara.register_driver :chrome do |app|
Capybara::Selenium::Driver.new(app, :browser => :chrome)
end
Capybara.app_host = 'https://www.website.com'
@session = Capybara::Session.new(:chrome)
end
# This is just an example method for the flow
def login(email, password, name)
@session.visit('/login')
@session.fill_in 'email', with: email
@session.fill_in 'password', with: password
@session.click_button 'Log in'
end
# Exit Capybara after everything is done
def exit
@session.driver.quit
@session = nil
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment