Software Quality Assurance & Testing Stack Exchange is a question and answer site for software quality control experts, automation engineers, and software testers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've got this HTML code

<input type="checkbox" value="abc" name="arr[]><br>
<input type="checkbox" value="abc1" name="arr[]><br>
<input type="checkbox" value="abc2" name="arr[]><br>

With this


I can check only the first checkbox, but I want check all check box in the same time. How I can do it?

share|improve this question
You probably can't check all the checkboxes at the same time (actually simultaneously). That's an action which would be impossible for a normal user, so selenium is unlikely to provide a way to do so. – vincebowdren Aug 6 '13 at 8:54
checkboxes = self.browser.find_elements_by_xpath("//input[@name='arr[]']")
for checkbox in checkboxes:
    if not checkbox.isSelected():

(Previous answer):

I am not yet familiar with the python syntax, but this is what you can do:

  1. Return all elements with the given xpath:

    Note that it is find_elements_by_xpath (plural)

  2. Loop through the list to check all checkbox

share|improve this answer

Try changing your Xpath to:

share|improve this answer

In Java that would be:

WebElement box = driver.findElement(By.xpath(".//*[@id='multi-selections']"));
List<WebElement> lc = box.findElements(By.tagName("input"));
for (int i = 0; i <= lc.size(); i++) {
share|improve this answer
Please, add an information you're answer is in Java, while question was about Python – dzieciou Nov 1 '12 at 17:04

In selenium IDE there is a command named check and un check so you can use the command for your testing case if needed.


share|improve this answer

Find element (singular returns only the first element that matches), whereas find_elements returns an iterable list of all matches. As Suchit explained, you can loop through the list.

You can also select an individual box in the list using the index. For example, to select the second box: driver.find_elements_by_xpath("//input[@name='arr[]']")[1].click()

share|improve this answer

Your Answer


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

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