我只在Chrome浏览器中看到这个。

完整的错误信息如下:

“org.openqa.selenium。WebDriverException:元素在点(411,675)不可点击。其他元素会收到点击:……”

“将接收点击”的元素位于相关元素的一侧,而不是在元素的顶部,也没有重叠,也没有在页面上移动。

我试过加一个偏移量,但也不行。该项目在显示的窗口上,不需要滚动。


当前回答

我根据Tony Lâmpada的回答做出了这个方法。它工作得很好。

def scroll_to(element)
  page.execute_script("window.scrollTo(#{element.native.location.x}, #{element.native.location.y})")
end

其他回答

我有同样的问题,并得到'其他元素将收到点击'错误显示,可见的元素。我发现没有其他解决方案,以触发与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();"
);

结果一切都很顺利

显然,这是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'))

我希望这只工作,但是,如果你试图点击的元素是一个链接…

你也可以使用JavaScript点击和滚动将不需要那么。

IJavaScriptExecutor ex = (IJavaScriptExecutor)Driver;
ex.ExecuteScript("arguments[0].click();", elementToClick);

在测试了所有提到的建议后,没有一个奏效。我写了这个代码。它有效,但并不漂亮

public void click(WebElement element) {
    //https://code.google.com/p/selenium/issues/detail?id=2766 (fix)
    while(true){
        try{
            element.click();
            break;
        }catch (Throwable e){
            try {
                Thread.sleep(200);
            } catch (InterruptedException e1) {
                e1.printStackTrace();
            }
        }
    }
}

public void click(String css) {
    //https://code.google.com/p/selenium/issues/detail?id=2766 (fix)
    while(true){
        try{
            driver.findElement(By.cssSelector(css)).click();
            break;
        }catch (Throwable e){
            try {
                Thread.sleep(200);
            } catch (InterruptedException e1) {
                e1.printStackTrace();
            }
        }
    }
}

在Rselenium中,当链接位于顶部窗口边框时,代码多次成功地使用了这种情况。简单的解决方案是使用sendKeysToElement(),如下所示。

if (unlist(webElem$isElementDisplayed())) {
    webElem$sendKeysToElement(list(key = "up_arrow"))  # Add "up arrow"..
    webElem$clickElement()  # ... before $clickElement