Checkboxes and Radio Buttons

The Filter Panel

<input type="checkbox" id="brand-nike" value="nike"> Nike
<input type="checkbox" id="brand-puma" value="puma"> Puma
<input type="radio" name="payment" id="pay-upi" value="upi"> UPI
<input type="radio" name="payment" id="pay-cod" value="cod"> Cash on Delivery

Select Only If Needed

WebElement nike = driver.findElement(By.id("brand-nike"));
if (!nike.isSelected()) nike.click();          // click toggles, so check first

driver.findElement(By.id("pay-upi")).click();
List<WebElement> payments = driver.findElements(By.name("payment"));
for (WebElement r : payments) {
    System.out.println(r.getDomAttribute("value") + " selected=" + r.isSelected());
}

Example

Output:

Run FilterTest.main()

Example output

upi selected=true
cod selected=false

Tip: Clicking a checkbox that is already ticked un-ticks it. Always check isSelected() first so the test works whatever the starting state.