1

I am trying to uncheck multiple check boxes at the same time in Selenium WebDriver in Java. I tried the suggestions at:

Selenium checkbox attribute "checked"

However, only one check box is unchecked at a time.

I would like to be able to uncheck multiple check boxes at the same time. The check boxes all have different ids.

Thank you for any insights.

Community
  • 1
  • 1

2 Answers2

1

I was able to figure this out in Java. Posting for others.

WebElement parent = driver.findElement(By.xpath("<enter parent xpath>"));  
List<WebElement> children = parent.findElements(By.cssSelector("input:checked[type='checkbox']"));  
for (int i = 0; i < children.size(); i++) { children.get(i).click(); } 
0
WE can use as well using "foreach" clause in jaca example like


Webelement parent = driver.findElement(By.xpath("<enter parent xpath>"));  

List<WebElement> children = parent.findElements(By.cssSelector("input:checked[type='checkbox']"));  

foreach(Webelement we : children)
{
we.click()
}