1

I want to get all the checkboxes in my page and iterate over them to check whether they are clickable (enabled) or not. For this purpose I used driver.find_elements_by_xpath(element_xpath), this method returns a list of all checkboxes and I can call a click function for each of them. The problem is after I check 2 checkboxes the rest of checkboxes became disable and I can't call the click function. I couldn't find any way to check either the checkbox is still clickable or not; since I do have a WebElement of each checkbox, not the string of them I couldn't use element_to_be_clickable or presence_of_element_located. Since

element = WebDriverWait(driver, 10).until(
                    EC.element_to_be_clickable((By.XPATH, element_xpath))
                )

is looking for element as string with eitehr is an Id, CSS, XPath or ...

I have read here that with element.get_attribute('outerHTML') I can get the HTML tag which surrounded my element but then how can I use it to see if the element is clickable?

all_check_box = ".//*[@type='checkbox']"
clickable_elements = driver.find_elements_by_xpath(all_check_box)
for elem in clickable_elements:
    try:
        WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.XPATH, elem))) #it's not working!!!
    except Exception as e:
         logging.error("couldn't Click")

Also for some reasons when I use is_enabled() it's always True.

all_check_box = ".//*[@type='checkbox']"
clickable_elements = driver.find_elements_by_xpath(all_check_box)
for elem in clickable_elements:
    print elem.is_enabled() # It's always True
    elem.click()
Am1rr3zA
  • 7,115
  • 18
  • 83
  • 125

0 Answers0