How to Uncheck All checkboxes Using Cucumber/Capybara
Sometimes while automating we need to have all checkboxes unchecked as a precondition or baseline state in a given page.We can do that in Cucumber/Capybara using following code:
Similar logic can be developed for other types of objects if required or better object type and locator detail can be passed as parameters to achieve higher level of abstraction which will work for any type of objects.
all('input[type=checkbox]').each do |checkbox| if checkbox.checked? then checkbox.click end end