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

完整的错误信息如下:

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

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

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


当前回答

调试"元素在点上不可点击"错误

要处理此错误,请使用此代码向下滚动。

browser.execute_script("window.scrollTo(0, 300);")

其他回答

您需要在该元素上使用焦点或滚动。您可能还必须使用显式等待。

WebElement firstbutton= driver.findElement(By.xpath("Your Element"));
Actions actions = new Actions(driver);
actions.moveToElement(element);
actions.perform();

OR

元素是不可点击的,因为它上面有一个旋转/覆盖:

By loadingImage = By.id("loading image ID");
WebDriverWait wait = new WebDriverWait(driver, timeOutInSeconds);
wait.until(ExpectedConditions.invisibilityOfElementLocated(loadingImage));

OR

Point p= element.getLocation();
Actions actions = new Actions(driver);
actions.moveToElement(element).movebyoffset(p.x,p.y).click().perform();

OR

如果仍然不能工作,请使用JavascriptExecutor

JavascriptExecutor executor = (JavascriptExecutor)driver;
executor.executeScript("arguments[0].click();", firstbutton);

如果你试图点击一个被禁用的输入或按钮,这种情况也会发生,在这种情况下,元素没有重叠,但它是不可点击的。

我也面临着同样的问题,我使用了延迟,这在我这边很有效。Page正在刷新和获取其他定位器。

Thread.sleep(2000);
        Click(By.xpath("//*[@id='instructions_container']/a"));

今天我遇到了同样的问题。如果我说我是如何解决问题的,你不会相信我。

通过最大化浏览器大小

是的,这是一个指针问题,意味着浏览器的大小。为此,您只需要手动或通过代码最大化窗口大小。

你可以用JS模拟点击:

public void click(WebElement element) {
    JavascriptExecutor js =(JavascriptExecutor)driver;
    js.executeScript("document.elementFromPoint(" + element.getLocation().x + "," + element.getLocation().y + ").click();");
}