I wanted to do find by class_name
and return last element among all elements.
In jquery, we can write something like below but that don't seems to work in capybara
find(".delete:last")
If you are using webkit
driver you can write something like -
find(".delete:last-child")
In capybara, you can get last element using below -
all(:css, ".delete").last
Is there any alternative to above?
I had the same problem and ended up using this method in Capybara 2.4
all('.delete').last
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With