Skip to content

Instantly share code, notes, and snippets.

@gurrenPizza
Created October 6, 2024 16:41
Show Gist options
  • Save gurrenPizza/815f4eb3065857de628e8b4096fdc346 to your computer and use it in GitHub Desktop.
Save gurrenPizza/815f4eb3065857de628e8b4096fdc346 to your computer and use it in GitHub Desktop.
Presenting the capybara syntax for Claudio Pacheco's medium article about automating form filling with selenium and ruby
require 'capybara/rspec'
require 'creek'
require 'selenium/webdriver'
Capybara.default_driver = :selenium # defaults to firefox, but you can have :selenium_chrome and :selenium_chrome_headless
# as well as other options
describe 'automating a form', type: :feature do
it 'submits a form - happier path' do
visit 'https://formy-project.herokuapp.com/form'
fill_in('Enter first name', with: 'Shazam')
fill_in('Enter last name', with: 'Oliveira')
fill_in('job-title', with: 'Super-herói')
choose('radio-button-1')
check('checkbox-2')
select('2-4', from: 'select-menu')
fill_in('datepicker', with: '10-06-2024')
click_on 'Submit'
expect(page).to have_content('The form was successfully submitted!')
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment