Skip to main content
simplfied click of element
Source Link

Suchit Parikh's Answer is close, but when selenium tries to click the second checkbox, it is likely that it will throw a StaleElementReferenceException

You can get by this by storing some unique information from the check boxes in another list, then iterate through that new list and finding the elements again.

Example:

   elements = self.driver.find_elements_by_xpath("//input[@name='arr[]']")
    
   element_list = []
   for elm in elements:
       element_list.append(elm.get_attribute('value'))
    
   for elem_value in element_list:
       WebDriverWait(self.driver, 5).until(expected_conditions.element_to_be_clickable(find_element_by_xpath(By.XPATH, "//input[@value='" + elem_value + "']"))).click()

Suchit Parikh's Answer is close, but when selenium tries to click the second checkbox, it is likely that it will throw a StaleElementReferenceException

You can get by this by storing some unique information from the check boxes in another list, then iterate through that new list and finding the elements again.

Example:

elements = self.driver.find_elements_by_xpath("//input[@name='arr[]']")

   element_list = []
   for elm in elements:
       element_list.append(elm.get_attribute('value'))

   for elem_value in element_list:
       WebDriverWait(self.driver, 5).until(expected_conditions.element_to_be_clickable((By.XPATH, "//input[@value='" + elem_value + "']"))).click()

Suchit Parikh's Answer is close, but when selenium tries to click the second checkbox, it is likely that it will throw a StaleElementReferenceException

You can get by this by storing some unique information from the check boxes in another list, then iterate through that new list and finding the elements again.

Example:

   elements = self.driver.find_elements_by_xpath("//input[@name='arr[]']")
    
   element_list = []
   for elm in elements:
       element_list.append(elm.get_attribute('value'))
    
   for elem_value in element_list:
       self.driver.find_element_by_xpath("//input[@value='" + elem_value + "']").click()
Source Link

Suchit Parikh's Answer is close, but when selenium tries to click the second checkbox, it is likely that it will throw a StaleElementReferenceException

You can get by this by storing some unique information from the check boxes in another list, then iterate through that new list and finding the elements again.

Example:

elements = self.driver.find_elements_by_xpath("//input[@name='arr[]']")

   element_list = []
   for elm in elements:
       element_list.append(elm.get_attribute('value'))

   for elem_value in element_list:
       WebDriverWait(self.driver, 5).until(expected_conditions.element_to_be_clickable((By.XPATH, "//input[@value='" + elem_value + "']"))).click()