本文翻译自:Debugging “Element is not clickable at point” error
I see this only in Chrome. 我只在Chrome中看到这一点。
The full error message reads: 完整的错误消息显示:
"org.openqa.selenium.WebDriverException: Element is not clickable at point (411, 675). Other element would receive the click: ..." “org.openqa.selenium.WebDriverException:元素在点(411,675)处不可点击。其他元素将收到点击:...”
The element that 'would receive the click' is to the side of the element in question, not on top of it and not overlapping it, not moving around the page. “将接收点击”的元素位于相关元素的一侧,而不是位于其上方且不与其重叠,而不是在页面上移动。
I have tried adding an offset, but that does not work either. 我试过添加一个偏移量,但这也不起作用。 The item is on the displayed window without any need for scrolling. 该项目位于显示的窗口上,无需滚动。
#1楼
参考:https://stackoom.com/question/nxsX/调试-元素在点上无法点击-错误
#2楼
There seems to be a bug in chromedriver for that (the problem is that it's marked as won't fix) --> GitHub Link chromedriver中似乎有一个错误(问题是它被标记为无法修复) - > GitHub Link
(place a bounty on FreedomSponsors perhaps?) (也许会给自由赞助商带来赏金?)
There's a workaround suggested at comment #27. 评论#27中提出了一种解决方法。 Maybe it'll work for you. 也许它对你有用。
#3楼
I was facing a similar problem whre i have to check two check boxes one after the other.But i was getting the same above error.hence i added wait in between my steps for checking the checkboxes....its working fine and great.here are the steps:- 我面临一个类似的问题,我必须一个接一个地检查两个复选框。但我得到了相同的上述错误。因此我在我的步骤之间添加等待检查复选框....它的工作正常和伟大。以下是步骤: -
When I visit /administrator/user_profiles
And I press xpath link "//*[@id='1']"
Then I should see "Please wait for a moment..."
When I wait for 5 seconds
And I press xpath link "//*[@id='2']"
Then I should see "Please wait for a moment..."
When I visit /administrator/user_profiles_updates
#4楼
Apparently this is the result of a "Won't Fix" bug in the Chrome driver binary. 显然,这是Chrome驱动程序二进制文件中“无法修复”错误的结果。
One solution that worked for me (Our Mileage May Vary) can be found in this Google Group discussion, Comment #3: 一个对我有用的解决方案(我们的里程可能会变化)可以在Google Group讨论中找到,评论#3:
https://groups.google.com/forum/?fromgroups=#!topic/selenium-developer-activity/DsZ5wFN52tc https://groups.google.com/forum/?fromgroups=#!topic/selenium-developer-activity/DsZ5wFN52tc
The relevant portion is right here: 相关部分就在这里:
I've since worked around the issue by navigating directly to the href of the parent anchor of the span. 我已经解决了这个问题,直接导航到span的父锚点的href。
driver.Navigate().GoToUrl(driver.FindElement(By.Id(embeddedSpanIdToClick)).FindElement(By.XPath("..")).GetAttribute("href")); 。driver.Navigate()GoToUrl(driver.FindElement(By.Id(embeddedSpanIdToClick))FindElement(By.XPath( “.. ”))的getAttribute(的“ href”));
In my case, I'm using Python, so once I got the desired element, I simply used 就我而言,我正在使用Python,所以一旦我得到了所需的元素,我就会使用它
driver.get(ViewElm.get_attribute('href'))
I would expect this to only work, however, if the element you are trying to click on is a link... 我希望这只能起作用,但是,如果你想点击的元素是一个链接......
#5楼
I had the same problem and it was caused by an id conflict between the div and the link inside the div. 我有同样的问题,它是由div和div内部的链接之间的ID冲突引起的。 So driver was clicking on the div instead of the link that I wanted. 所以司机点击了div而不是我想要的链接。 I changed the div id and it worked properly. 我更改了div id并且它正常工作。
Before: 之前:
<div id="logout"><a id="logout" href="logoutLink">logout</a></div>
After: 后:
<div id="differentId"><a id="logout" href="logoutLink">logout</a></div>
#6楼
I had the same issue, tried all offered solutions but they did not work for me. 我有同样的问题,尝试了所有提供的解决方案,但他们不适合我。 eventually I used this: 最后我用过这个:
JavascriptExecutor js = (JavascriptExecutor) driver;
js.executeScript("var evt = document.createEvent('MouseEvents');" + "evt.initMouseEvent('click',true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0,null);" + "arguments[0].dispatchEvent(evt);", findElement(element));
Hope this helps 希望这可以帮助