Element is not clickable at point (x,y.5) because another element obscures it

点点圈 提交于 2021-02-07 03:25:39

问题


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?


回答1:


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




回答2:


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

element = driver.find_element_by_xpath(xpath)
driver.execute_script("arguments[0].click();", element)



回答3:


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]);


来源:https://stackoverflow.com/questions/49252880/element-is-not-clickable-at-point-x-y-5-because-another-element-obscures-it

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!