Python - Selenium Robot - Element is not Interactable

8 hours ago 1
ARTICLE AD BOX

If we take your HTML fragment and wrap it in a minimal HTML document as follows:

<!DOCTYPE html> <html lang="en"> <title>Stackoverflow</title> <meta charset="utf-8"> </head> <body> <table> <tr> <td class="checkbox-td-row pl-3"> <input type="hidden" id="io_id" name="io_id[]"> <input id="Mg==" name="mechanical_is_check[]" type="checkbox" value="Mg==">  <label class="checkbox-lable-row" for="Mg==">Pressure Vessel</label> </td> </tr> </table> </body> </html>

...then...

from pathlib import Path from selenium.webdriver import Chrome from selenium.webdriver.support import expected_conditions as EC from selenium.webdriver.common.by import By from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.remote.webelement import WebElement from selenium.webdriver.common.action_chains import ActionChains DRIVER: Chrome def click(e: WebElement) -> None: assert e ActionChains(DRIVER).move_to_element(e).click().perform() with Chrome() as DRIVER: path = Path("~/Documents/Python/apr27.html").expanduser() DRIVER.get(path.as_uri()) wait = WebDriverWait(DRIVER, 5) ec = EC.presence_of_element_located loc = (By.ID, "Mg==") click(wait.until(ec(loc))) input("Press enter: ")

Note that it's the input element with the ID of "Mg==" that you need to click.

Read Entire Article