[Fixed]-Selenium: Element not clickable … Other Element Would Receive Click

11👍

Your Answer lies within your question.

  1. Error says ‘add_task_sidebar_link’ not clickable at point - (61, 24.300003051757812) This is where another element is – Other element would receive the click: <a class="navbar-brand" href="#"></a> where the click is being attempted. Since you did not maximize the browser, you are not able to get the point co ordinates correctly.
  2. In order for future tests to not break, pls scroll to that element. Refer to this post (Selenium python unable to scroll down). Check Action chains (http://selenium-python.readthedocs.org/api.html#module-selenium.webdriver.common.action_chains)

30👍

Extremely late to the party, but I have an extremely simple solution that worked for me. Instead of doing .click(), simply do

.send_keys(selenium.webdriver.common.keys.Keys.SPACE)

With the element selected, the spacebar can toggle the selection. Worked for me!

4👍

Ran into a similar problem (same error) and tried Major Major’s solution above using send_keys + sending the space bar to simulate a click rather than a mouse click.

Major Major’s solution:

.send_keys(selenium.webdriver.common.keys.Keys.SPACE)

I hit a new error trying to run this, pointing at ‘selenium’. Removing that keyword from the code fixed the issue, and allowed me to click the element.

Final successful code snippet used:

my_variable = driver.find_element_by_xpath('//*[@id="myId"]') #this is the checkbox
my_variable.send_keys(webdriver.common.keys.Keys.SPACE)

0👍

This has more to do with elements ‘covering’ each other. Which makes sense if it’s happening on non-maximized windows. Could also happen if there was a popup/floating div or another element which covering the element you’re actually trying to click on.

Remember, selenium is mimicking the user, so you can’t normally do an action which the user wouldn’t have been able to do – like click on an element which is covered by another.

A potential workaround for this would be to use Javascript to find the element and click on it. Example here:

labels = driver.find_elements_by_tag_name("label")
inputs = driver.execute_script(
    "var labels = arguments[0], inputs = []; for (var i=0; i < labels.length; i++){" +
    "inputs.push(document.getElementById(labels[i].getAttribute('for'))); } return inputs;", labels)

0👍

In my current Capybara project, I often get “Element not clickable” errors. The reason for this kind of error is that web page doesn’t loads well enough to locate the element. As you have mentioned that the tests previously passed and you haven’t edited that part of the code base, So you can do the following things to get pass through this:

  1. Put some more wait time before locating “add_task_sidebar_link”. So that the page loads fully.
  2. Still if the test fails even after adding wait, then add some method to take screenshot before clicking the element. This will help debugging the test.

0👍

Since recently the Firefox driver checks that the element at the clicking position is the element supposed to be clicked.
This error means that when the driver tries to click the element, an other one is on top of it.
Unfortunatelly, the driver doesn’t automatically scroll the containers and raises this error instead.

On way to handle this issue is to scroll the element in the center of the screen and try to click again.
Monkey patch for the click method :

JS_SCROLL_ELEMENT_CENTER_WINDOW = """\
  var element = arguments[0];
  element.scrollIntoView(true);
  var y = (window.innerHeight - element.offsetHeight) / 2;
  if (y > 0) {
    for (var e=element; e; e=e.parentElement) {
      if (e.scrollTop) {
        var yy = Math.min(e.scrollTop, y);
        e.scrollTop -= yy;
        if ((y -= yy) < 1)
          return;
      }
    }
    window.scrollBy(0, -y);
  }
  """

def click(self):
  try:
    self._execute(Command.CLICK_ELEMENT)
  except:
    self._parent.execute(Command.EXECUTE_SCRIPT, \
      {'script': JS_SCROLL_ELEMENT_CENTER_WINDOW, 'args': [self]})
    self._execute(Command.CLICK_ELEMENT)

from selenium.webdriver.remote.webelement import WebElement
from selenium.webdriver.remote.command import Command
WebElement.click = click

0👍

I had the same issue: due to a pop-up window, the element I had to click on would drift off the screen and become unclickable.

Scrolling the page to the element worked.

In Python:

elem = driver.find_element_by_tag_name("html")
elem.send_keys(Keys.END)
👤rp2017

Leave a comment