This is the how my HTML looks like:

     <td class = 'text-bar'> id </td>
        <input type="checkbox" size = "20" value= 'Yes' id ="x_id1">

I have 19 checkboxes and I want to select checkboxes in-between.

what would be the easiest way to achieve that:

My current code looks like this which selects all the checkboxes right now. How do i add if condition to select particular checkboxes in-between ??:

checkboxes = driver.find_elements_by_css_selector("input[type='checkbox']")
    for checkbox in checkboxes:
        if not checkbox.is_selected():

Appreciate your help.. :)

1 Answer 1


This is what I came up with to select particular checkboxes by converting them into a list. In my code, I am trying to select checkboxes between 3 and 15 (which is not dynamic but this is what I was looking for:

checkboxes = driver.find_elements_by_css_selector("input[type= 'checkbox']")
    chk = [checkbox for checkbox in checkboxes]
    for i in chk[4:15]:
        if not i.is_selected():

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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