Skip to content

Instantly share code, notes, and snippets.

@ebsaral
Last active August 29, 2015 14:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ebsaral/f00686f917438e246afc to your computer and use it in GitHub Desktop.
Save ebsaral/f00686f917438e246afc to your computer and use it in GitHub Desktop.
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