I use selenium
with python
and want to mark a checkbox by clicking on it.
After having identified the <input>
tag of the checkbox with selenium, I attempt to click on it with
checkbox.click()
However, it throws the ElementClickInterceptedException
.
I identify the checkbox I want to click on through a loop. When I try to click on the checkbox outside of the loop (by manually running the code after it was identified and saved to a variable), I found two things:
- All things equal, I still get the exception
- When I click in the browser window once (that was opened with selenium) and then run
checkbox.click()
, it works as expected
Any ideas why and how I could attempt to slove this issue (i.e. being able to click on the checkbox within the loop)?
Thanks!
CodePudding user response:
You either deal with the overlapping element or use javascript
driver.execute_script("arguments[0].click();", checkbox)
CodePudding user response:
Sometimes, the checkbox is not directly interactable. You may have to click on the label/text next to the checkbox.
or May be you have to wait till the element is clickable since your are running in a loop.