//Checkbox
Suppose there is a single check box in the form to find the Element a Write a below code
f.findElement(By.name("")).click();
Suppose more no of check box in the page,we have to short the code.
First collect all the Elements(checkbox) and find it have same element name,it is same write the below code to test the checkbox.
Example Site
//To collect all the Elements and Save in the WebElement
WebElement
s=f.findElement(By.xpath(""));
for(int i=0;i<=2;i++) //using for loop and put the conditions for how many checkbox are there
{
s.click(); //When loop increment it select the checkbox as one by one.
System.out.println(s.isSelected());
}
To Select and Deselect the Checkbox
//To collect all the Elements and Save in the WebElement
WebElement
s=f.findElement(By.xpath(""));
for(int i=0;i<=2;i++) //using for loop and put the conditions for how many checkbox are there
{
s.click(); //When loop increment it select the checkbox as one by one.
s.click(); //When loop increment it Deselect the checkbox as one by one.
System.out.println(s.isSelected());
}