Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to obtain the value of a checkbox in capybara?

I want to check if a checkbox is checked using cucumber and capybara. I have checked the checkbox in my previous step and want to verify it by obtaining the value of the checkbox.

like image 303
Dev S Avatar asked Mar 05 '12 16:03

Dev S


1 Answers

Use the checked? method

e.g.:

my_box = find('#some_checkbox') my_box.should be_checked  # Before Rspec 2.11  # OR using new syntax expect(my_box).to be_checked  # Rspec 2.11 
like image 103
Jon M Avatar answered Sep 18 '22 19:09

Jon M