11

I am trying to click on an element but getting the error:

Element is not clickable at point (x,y.5)

because another element obscures it.

I have already tried moving to that element first and then clicking and also changing the co-ordinates by minimizing the window and then clicking, but both methods failed. The possible duplicate question has answers which I have already tried and none of them worked for me.

Also, the same code is working on a different PC.

How to resolve it?

Shubham srivastava
  • 157
  • 1
  • 3
  • 11
  • if you watch the test run, can you see what is obscuring it? – Breaks Software Mar 13 '18 at 11:22
  • Possible duplicate of [Element MyElement is not clickable at point (x, y)... Other element would receive the click](https://stackoverflow.com/questions/44724185/element-myelement-is-not-clickable-at-point-x-y-other-element-would-receiv) – undetected Selenium Mar 13 '18 at 12:28
  • No, even if another element would obscure it, moving to the element and then clicking should work and also the same code is working on different PC. – Shubham srivastava Mar 15 '18 at 16:44

4 Answers4

30

This often works when element.click() does not:

element = driver.find_element_by_xpath(xpath)
driver.execute_script("arguments[0].click();", element)
wrecks
  • 476
  • 1
  • 4
  • 5
11

There is possibly one thing you can do. It is very crude though, I'll admit it straight away.

You can simulate a click on the element directly preceding the element in need, and then simulate a key press [TAB] and [ENTER].


Actually, I've been seeing that error recently. I was using the usual .click() command provided by bare selenium - like driver.find_element_by_xpath(xpath).click().

I've found that using ActionChains solved that problem.

Something like ActionChains(driver).move_to_element(element).click().perform() worked for me.

You will need:

from selenium.webdriver.common.action_chains import ActionChains

Alichino
  • 1,598
  • 2
  • 15
  • 24
1

It was @wrecks idea, but If using php-webdriver you can use below code:

$element = $driver->findElement(WebDriverBy::cssSelector($id_login));
$driver->executeScript("arguments[0].click();", [$element]);
-2

I found that sometimes the webpage is not fully loaded and the answer is as simple as adding a time.sleep(2)