enter image description hereenter image description hereI want to know how to select single checkbox from multiple checkboxes one by one


On a web Page, there are multiple entries having checkboxes in front of each entry. For each entry there is an edit button on right side. I want to select a single checkbox and then click on the edit button for that particular entry. on editing, a pop-up window will open. make some changes and click on the save button on the pop-up window. I need to do the same for each entry

I have added the html

  • if you need more detailed help, please provide HTML code
    – Yu Zhang
    Jul 23, 2016 at 20:59
  • After the edit pop-up is submitted the checkbox remains checked? The html provided does not contains enough details, i expected an html that contains the structure of the table, for example the header + first 2-3 lines in full format(with edit part). The checkbox changes any attribute when is checked? The edit button appears only for selected checkbox? else i don't see the role of the checkbox to be checked, maybe it enables the edit button. We need details.
    – lauda
    Jul 25, 2016 at 13:32

4 Answers 4


You have not provided HTML code, but please feel free to use the following example as a reference:

Say your HTML codes looks like:

<table class="transaction-table" 
        <li value="152" /li>
        <li value="153" /li>
        <li value="154" /li>

where each element li represent each transaction row.

What you can do is:

from selenium import webdriver

firefox = webdriver.Firefox()
firefox.get("put your url here");
transactionElements = firefox.find_elements_by_css_selector("table[class='transaction-table'] li");
for element in transactionElements:

Hope it helps.


Try this in Java,

List<WebElement> elements=driver.findElements(By.xpath(".//*[starts-with(@id,'ct100_cPH_rptrDisplayRecords')]"));
int numberOfElements=elements.size();
for(int i=0;i<numberOfElements;i++){
    //click edit button and manage the popup
    // Uncomment below code if the selection of the check box is not automatically cleared on closing the popup
    /* elements=driver.findElements(By.xpath(".//*[starts-with(@id,'ct100_cPH_rptrDisplayRecords')]"));
    elements.get(i).click(); */
  • Hi, Same id is for Checkbox, Edit button and Image
    – saurabh
    Jul 26, 2016 at 8:06
  • Can you share HTML code for checkbox, edit button and image Jul 26, 2016 at 10:04

If you don't checkbox, try to get a selector for a checkbox from the body of the table, if multiple found the first one is used.

One way of clicking on the edit for the checkbox that is checked is to get an Xpath selector based on the checked value.

Please provide html code for what the image is describing for a more particular answer.

<input id="ctl00_cPH_rptrDisplayRecords_ctl03_chkMoveTranSingle" name="ctl00$cPH$rptrDisplayRecords$ctl03$chkMoveTranSingle" value="2469035" type="checkbox">

<input id="ctl00_cPH_rptrDisplayRecords_ctl05_chkMoveTranSingle" name="ctl00$cPH$rptrDisplayRecords$ctl05$chkMoveTranSingle" value="2469031" type="checkbox">

<input id="ctl00_cPH_rptrDisplayRecords_ctl08_chkMoveTranSingle" name="ctl00$cPH$rptrDisplayRecords$ctl08$chkMoveTranSingle" value="2781014" type="checkbox">

<input id="ctl00_cPH_rptrDisplayRecords_ctl02_chkMoveTranSingle" name="ctl00$cPH$rptrDisplayRecords$ctl02$chkMoveTranSingle" value="2469037" type="checkbox">
import java.util.List;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;

public class test6 {

    public static void main(String[] args) {
        WebDriver driver=new FirefoxDriver();
        List <WebElement> li= driver.findElements(By.xpath("//input[@type='checkbox']"));
                for(int i=0;i<=li.size()-1;i++)


  • Your answer would be better if it described how this solution solved the OP's problem.
    – Kate Paulk
    Mar 16, 2018 at 11:22

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.