Capybara Workout

Refer to the Capybara cheat sheet and use Capybara to instruct the automated browser to click on the buttons below.

Buttons

These buttons can be clicked by their unique values


        pry(main)> click_button 'Click me!'

Radio Buttons

Input elements can also be selected by their 'name' attributes

<input type='checkbox' name='first'>
  • Check me!
  • And me.

        pry(main)> check('first')

Buttons: identical values

Try to click these buttons by their values. What error do you get? Look at using Capybara's `within` syntax

<section class='third'>
</section>

<section class='fourth'>
</section>

        pry(main)> within('section .fourth') do
                     click_button "We're the same...but in different sections"
                   end

Buttons: different IDs

These buttons should be targetted by their IDs. Hint: this is easier than you think.

<button id='left'>

        pry(main)> click_button "We're the same but we have different IDs"

Buttons: different classes

These buttons should be targetted by their classes.

<button class='left'>

        pry(main)> find('button.left').click

Forms

Try to fill in this form!


        pry(main)> fill_in 'name', with: 'Bob'