I have an element (checkbox) that I want to click:
<ins tabindex="0" role="checkbox" class="check-helper" style="position: absolute; top: 0%; left: 0%; display: block; width: 100%; height: 100%; margin: 0px; padding: 0px; cursor: pointer;" aria-checked="false" aria-disabled="false"></ins>
I can find the element with Selenium Python...
element = driver.find_element_by_class_name('check-helper')
...but clicking on it (element.click()
) results in this trace:
---------------------------------------------------------------------------
ElementNotInteractableException Traceback (most recent call last)
<ipython-input-379-cf25f85114ab> in <module>
----> 1 element.click()
~\AppData\Local\conda\conda\envs\robotics\lib\site-packages\selenium\webdriver\remote\webelement.py in click(self)
78 def click(self):
79 """Clicks the element."""
---> 80 self._execute(Command.CLICK_ELEMENT)
81
82 def submit(self):
~\AppData\Local\conda\conda\envs\robotics\lib\site-packages\selenium\webdriver\remote\webelement.py in _execute(self, command, params)
631 params = {}
632 params['id'] = self._id
--> 633 return self._parent.execute(command, params)
634
635 def find_element(self, by=By.ID, value=None):
~\AppData\Local\conda\conda\envs\robotics\lib\site-packages\selenium\webdriver\remote\webdriver.py in execute(self, driver_command, params)
319 response = self.command_executor.execute(driver_command, params)
320 if response:
--> 321 self.error_handler.check_response(response)
322 response['value'] = self._unwrap_value(
323 response.get('value', None))
~\AppData\Local\conda\conda\envs\robotics\lib\site-packages\selenium\webdriver\remote\errorhandler.py in check_response(self, response)
240 alert_text = value['alert'].get('text')
241 raise exception_class(message, screen, stacktrace, alert_text)
--> 242 raise exception_class(message, screen, stacktrace)
243
244 def _value_or_default(self, obj, key, default):
ElementNotInteractableException: Message: element not interactable
(Session info: chrome=78.0.3904.97)
When I locate the element in the console and use $0.click()
to click on it, the checkbox is clicked. I tried using JavaScript in my code to click on it...
element = driver.find_element_by_class_name('check-helper')
driver.execute_script("arguments[0].click();", element)
...but this resulted in it running with no errors, but not actually clicking the checkbox.
Where is the disconnect between the console and my code, and why can I not click on this element from my code?