Skip to content Skip to sidebar Skip to footer

Check A Checkbox In An Html Page With Python 3.5 & Selenium

I am trying to select all checkboxes that appear on an HTML page with Python 3.5 and Selenium. The final goal is obviously to manipulate them, but I can't even manage to select the

Solution 1:

I'm also not sure if that page has frames, but I usually do it this way.

driver.switch_to.default_content()

before I scrape elements. Then I use this function to query the element.

defget_element(by_arg, by_method=By.ID):
    return WebDriverWait(driver, MAX_TIMEOUT).until(
           EC.presence_of_element_located((by_method, by_arg))
       )

so for your case it would be.

check_box = get_element(".//input[@type='checkbox']", By.XPATH)

Solution 2:

You were indeed right, the correct iframe was not chosen and so I wasn't able to interact with its checkboxes.

driver.switch_to.frame(driver.find_element_by_id('catFrame')) driver.find_element_by_css_selector('div.idtTopSm tr input').click()

But do you know why the page still doesn't "listen" to the checkbox click? I mean, the blue button is supposed to turn blue and be "clickable" once a checkbox has been clicked.

Post a Comment for "Check A Checkbox In An Html Page With Python 3.5 & Selenium"