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:

all('input[type=checkbox]').each do |checkbox|
 if checkbox.checked? then 
  checkbox.click
 end
end
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.

Comments

Popular posts from this blog

Testing Webservice with SoapUI Having Windows Authentication

Data Driven Testing Using Selenium -WebDriver in Python

How to Re-run Failed Scenarios in Cucumber