我只在Chrome浏览器中看到这个。
完整的错误信息如下:
“org.openqa.selenium。WebDriverException:元素在点(411,675)不可点击。其他元素会收到点击:……”
“将接收点击”的元素位于相关元素的一侧,而不是在元素的顶部,也没有重叠,也没有在页面上移动。
我试过加一个偏移量,但也不行。该项目在显示的窗口上,不需要滚动。
我只在Chrome浏览器中看到这个。
完整的错误信息如下:
“org.openqa.selenium。WebDriverException:元素在点(411,675)不可点击。其他元素会收到点击:……”
“将接收点击”的元素位于相关元素的一侧,而不是在元素的顶部,也没有重叠,也没有在页面上移动。
我试过加一个偏移量,但也不行。该项目在显示的窗口上,不需要滚动。
当前回答
我也遇到了同样的问题,这是由div和div内链接之间的id冲突引起的。所以驱动程序点击了div而不是我想要的链接。 我改变了div id,它正常工作。
之前:
<div id="logout"><a id="logout" href="logoutLink">logout</a></div>
后:
<div id="differentId"><a id="logout" href="logoutLink">logout</a></div>
其他回答
我根据Tony Lâmpada的回答做出了这个方法。它工作得很好。
def scroll_to(element)
page.execute_script("window.scrollTo(#{element.native.location.x}, #{element.native.location.y})")
end
显然,这是Chrome驱动二进制文件中“不会修复”错误的结果。
一个对我有效的解决方案(我们的里程可能有所不同)可以在这个谷歌小组讨论中找到,评论#3:
https://groups.google.com/forum/?fromgroups= !主题/ selenium-developer-activity / DsZ5wFN52tc
相关的部分在这里:
从那以后,我通过直接导航到的href来解决这个问题 跨度的父锚。 driver.Navigate () .GoToUrl (driver.FindElement (By.Id (embeddedSpanIdToClick)) .FindElement (By.XPath(“。”)).GetAttribute(“href”));
在我的例子中,我使用的是Python,所以一旦我得到了所需的元素,我就简单地使用
driver.get(ViewElm.get_attribute('href'))
我希望这只工作,但是,如果你试图点击的元素是一个链接…
我做了一种蛮力点击,它对我有用。
try:
elem.click()
except:
print "failed to click"
size = elem.size
mid_of_y = int(size["height"])/2
stepts_to_do_to_left = int(size["width"])
while stepts_to_do_to_left > 0:
try:
print stepts_to_do_to_left, mid_of_y
action = webdriver.common.action_chains.ActionChains(driver)
action.move_to_element_with_offset(elem, mid_of_y, stepts_to_do_to_left)
action.click()
action.perform()
print "DONE CLICK"
break
except:
pass
我得到这个bug是因为我测试了一个悬停,然后需要点击工具提示下面的链接。解决方案是添加page.find('.sp-logo')。鼠标悬停在click_link之前以获得工具提示。
我有同样的问题,并得到'其他元素将收到点击'错误显示,可见的元素。我发现没有其他解决方案,以触发与javascript点击。
我更换:
WebElement el = webDriver.findElement(By.id("undo-alert"));
WebElement closeButton = el.findElement(By.className("close"));
// The following throws 'Element is not clickable at point ... Other element
// would receive the click'
closeButton.click();
:
((JavascriptExecutor) webDriver).executeScript(
"$('#undo-alert').find('.close').click();"
);
结果一切都很顺利