How to verify max 2 checkbox in a row

How to verify the checkbox on a field, maximum 10, 2 in a row, and the checkbox is checked?

// To verify checkbox is checked


Boolean isCheckboxChecked =

driver.findElement(By.xpath("//*[contains(@class, 'checkboxSection')]//input[@type='checkbox']")).isSelected();

// To verify max checkbox on that section is 10


Boolean isCheckboxMaxTen =

driver.findElements(By.xpath("//*[contains(@class, 'checkboxSection')]//input[@type='checkbox']")).size() <= 10;

// To verify max 2 checkbox in a row
Any idea how to verify max 2 checkbox in a row

if ((isCheckboxChecked == true) && (isCheckboxMaxTen == true) && (isCheckboxTwoInARow == true)){
// Pass
}
else
{
// Fail
}

Add Comment
0 Answer(s)

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.