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

完整的错误信息如下:

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

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

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


当前回答

我有同样的问题,尝试了所有提供的解决方案,但它们都不适合我。 最后我用了这个:

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

希望这能有所帮助

其他回答

我遇到了这个问题,它似乎是由(在我的情况下)点击一个元素,弹出一个div在前面点击的元素。我通过在一个大的try catch块中包装我的点击来解决这个问题。

而不是

webdriver.findElement(By.id("id1")).click();

试着使用

click(By.id("id1"));

void click(final By byLocator) {
    waitFor(new ExpectedCondition<Boolean>() {
        @Override
        public Boolean apply(WebDriver driver) {
            WebElement element = driver.findElement(byLocator);
            if (element.isDisplayed()) {
                try {
                    element.click();
                    return true;
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
            return false;
        }

        @Override
        public String toString() {
            return "Element located " + byLocator + " clicked";
        }
    });
}
WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(15));
wait.Until(SeleniumExtras.WaitHelpers.ExpectedConditions.ElementToBeClickable(By.<Id or anything>));

希望这能有所帮助。

如果页面中已经加载了jQuery,可以执行以下javascript命令:

"$('#" + element_id + "').click()"

使用python executor的示例:

driver.execute_script("$('#%s').click()" % element_id)

在chromedriver中似乎有一个bug(问题是它被标记为不会修复) ——> GitHub链接

(也许是对“自由赞助者”的悬赏?)

在第27条评论中提出了一个解决方案。 也许这对你有用