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

完整的错误信息如下:

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

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

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


当前回答

我在python中运行selenium脚本时遇到了同样的问题。下面是我用来点击元素的:

from selenium.webdriver.common.action_chains import ActionChains


ActionChains(driver).click(element).perform()

其他回答

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

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

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

在Visual Studio 2013中,如果你启用BrowserLink -它会在屏幕底部显示一个BrowserLink导航栏。如果你想点击的项目在导航栏后面,它会给出错误。禁用BrowserLink为我解决了这个问题。

可能有很多因素会抛出这个错误。 首先,dom可能会在selenium webdriver捕获元素之后发生变化,或者在捕获元素之前元素中使用的所有java脚本都没有加载成功。 要解决这个问题,我们需要使用javascript等待或ajax等待如下。

wait = new WebDriverWait(driver, 30);
wait.until((ExpectedCondition<Boolean>) wd -> ((JavascriptExecutor) wd).executeScript("return document.readyState").equals("complete"));
        e_driver = new EventFiringWebDriver(driver);

其次,大多数提供软件qa服务的公司的工程师尝试使用java脚本执行器进行单击操作。

如果这也不起作用,那么使用Actions类执行action。

ruby / watir-webdriver /铬

我用了下面的技巧,看起来很管用:

#scroll to myelement
@browser.execute_script "window.scrollTo(#{myelement.element.wd.location[0]},#{myelement.element.wd.location[1]})"

# click myelement
myelement.when_present.fire_event("click")