Skip to content Skip to sidebar Skip to footer

Cannot Click On Toggle With Selenium Because Of Elementnotinteractableexception

I am trying to click a toggle with Selenium Webdriver and Python but get the following exception: selenium.common.exceptions.ElementNotInteractableException: Message: element not

Solution 1:

you're trying to interact with the label. you want the input element:

 #remove the label from page
 driver.execute_script("document.querySelector(\"strong[for='opened']\").style.visibility = 'hidden';")

 toggle = driver.find_element_by_css_selector("#opened")
 toggle.click()

Solution 2:

The best bulletproof option which I use now is:

toggle = driver.find_element_by_css_selector(".toggle-switch>label[for=opened]")
driver.execute_script("arguments[0].click();", toggle)

In addition, sometimes I need to wait until an element that covers my toggle becomes not visible with:

 wait.until(EC.invisibility_of_element_located((By.CSS_SELECTOR, "my css selector")))

Post a Comment for "Cannot Click On Toggle With Selenium Because Of Elementnotinteractableexception"