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

完整的错误信息如下:

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

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

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


当前回答

当您使用分辨率大于1024x768的浏览器时,尝试最大化浏览器。

driver.manage().window().maximize();

其他回答

这可能会帮助那些正在使用WebdriverIO的人:

function(){
    var runInBrowser = function(argument) { 
        argument.click();
    };
    var elementToClickOn = browser.$('element');
    browser.execute(runInBrowser, elementToClickOn);
}

来源:https://www.intricatecloud.io/2018/11/webdriverio-tips-element-wrapped-in-div-is-not-clickable/

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

结果一切都很顺利

如果你在conf.js文件中使用下面这行代码,请将其注释掉,然后再试一次

browser.ignoreSynchronization = true;

这是由以下3种类型引起的:

1.单击该元素是不可见的。

使用Actions或JavascriptExecutor让它点击。

行动:

WebElement element = driver.findElement(By("element_path"));

Actions actions = new Actions(driver);

actions.moveToElement(element).click().perform();

由JavascriptExecutor:

JavascriptExecutor jse = (JavascriptExecutor)driver;

jse.executeScript("scroll(250, 0)"); // if the element is on top.

jse.executeScript("scroll(0, 250)"); // if the element is on bottom.

or

JavascriptExecutor jse = (JavascriptExecutor)driver;

jse.executeScript("arguments[0].scrollIntoView()", Webelement); 

然后单击元素。

2.在单击元素之前,页面会被刷新。

为此,让页面等待几秒钟。

3.元素是可点击的,但有一个旋转/覆盖在它的顶部

下面的代码将等待覆盖消失

By loadingImage = By.id("loading image ID");

WebDriverWait wait = new WebDriverWait(driver, timeOutInSeconds);

wait.until(ExpectedConditions.invisibilityOfElementLocated(loadingImage));

然后单击元素。

我在硒驱动的Chrome窗口开得太小的情况下见过这种情况。要点击的元素不在视口中,因此正在失败。

这听起来合乎逻辑……真正的用户必须调整窗口大小或滚动,以便能够看到元素,并实际上单击它。

在指示selenium驱动程序适当地设置窗口大小后,这个问题就消失了。这里描述了webdriver API。