Finding the last element with the same class in Capybara and filling it with some text
capybara, css, ruby, ruby-on-rails
Solution
What about:
within all('.foo').last do
find('.bar').set 'a value'
end
Check within and set.
Problem
I've following markup: ``` <div class='foo'> <form> <input class='bar' type='text'> </form> <div/> <div class='foo'> <form> <input class='bar' type='text'> </form> </div> ``` I'd like to fill input in the second `.foo` container. How I can achieve this in Capybara ?