Reputation: 3596
I am using the below code , The test case is not failing but the code is not checking the check-boxes.
@Test(priority=11)
public void Test_CheckBox_Check()throws InterruptedException {
List<WebElement> els = driver.findElements(By.xpath("//md-checkbox[@aria-checked='false']"));
System.out.println(Integer.toString(els.size()));
for ( WebElement el : els ) {
el.click();
}
}
Upvotes: 0
Views: 1694
Reputation: 3596
After adding some wait its working
@Test(priority=11)
public void Test_CheckBox_Check()throws InterruptedException {
Thread.sleep(2000);
List<WebElement> els = driver.findElements(By.xpath("//md-checkbox/div/div[@class='md-icon']"));
System.out.println(Integer.toString(els.size()));
for ( WebElement el : els ) {
Thread.sleep(2000);
el.click();
System.out.println(el.getText());
driver.findElement(By.xpath("//div[@class='col-xs-1']")).click();
}
Upvotes: 0
Reputation: 331
The locator you are using might be the causing the issue try with below:
//div[@class='ng-scope flex-20']//following::md-checkbox**[@role='checkbox']**
You may omit the part in asterisk if all the elements that are identified by md-checkbox are checkboxes.
Below code worked for me in another case:
List<WebElement> checkboxes = driver.findElements(By.xpath("//div[@class='control-group']//following::input[@type='checkbox']"));
for(WebElement check:checkboxes){
check.click();
}
Upvotes: 1