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.

2 Answers 2

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()
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.