2

I am using selenium with python and I try to click on element below. But every time shows the error (in starting was working) only getting error on this line and have tried CSS selector id and all.

  <span class="avatar" ng-click="showBlock($event);">
                        <img src="assets/images/user.png" alt="user image">
                    </span> 

selenium code ::

wait.until(EC.presence_of_element_located((By.XPATH,'//img[@alt="user image"]'))).click()

ERROR::

 self._execute(Command.CLICK_ELEMENT)
 return self._parent.execute(command, params)
 self.error_handler.check_response(response)

raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: unknown error: Element <img src="assets/images/user.png" alt="user image"> is not clickable at point (1333, 34). Other element would receive the click: <div id="page_preloader" style="display: block;">...</div>
  (Session info: chrome=81.0.4044.122)
2

1 Answer 1

1

The error Other element would receive the click: <div id="page_preloader"> means that the element page_preloader is above the element you try to click on. When Selenium tries to click on an element it checks if the click would go onto that element, it does not allow clicking on other elements.

These are situation I got this error:

  • There really is an element on top of the element you want to click on, it could be transparent and not visible with your eyes. Could be that Selenium is to fast, it finds the element while for example an loading div is still there.
  • The element is moving, because other elements are still being drawn. It found the element on a location, but when it tries to click another element is in its place.

I would:

  • Wait until page_preloader is hidden before trying to interact with the page.
  • Wait until the element is clickable instead of located. Located could also mean hidden, it just needs to be in the DOM. Not visible or clickable. Try: element_to_be_clickable

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.