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

完整的错误信息如下:

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

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

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


当前回答

我也遇到过类似的问题,我必须一个接一个地勾选两个复选框。但我得到了相同的上面的错误。因此,我在步骤之间添加了等待,以检查复选框....它工作得很好。以下是步骤:-

  When I visit /administrator/user_profiles
  And I press xpath link "//*[@id='1']"
  Then I should see "Please wait for a moment..."
  When I wait for 5 seconds
  And I press xpath link "//*[@id='2']"
  Then I should see "Please wait for a moment..."
  When I visit /administrator/user_profiles_updates

其他回答

我在点击Angular Material菜单中的一个按钮时就遇到了这个问题。每当我单击菜单中的按钮时,.cdk-overlay-窗格就会收到单击。解决方案是增加菜单内按钮的z-index。

.cdk-overlay-pane button {
  z-index: 1001;
}

当使用量角器时,这帮助了我:

var elm = element(by.css('.your-css-class'));
browser.executeScript("arguments[0].scrollIntoView();", elm.getWebElement());
elm.click();

在我的例子中,它在Firefox中运行正常,但在Chrome中失败了。在Chrome中,在更新Chrome驱动程序版本到最新版本后,该问题得到了修复。

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

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

我也遇到了同样的问题,这是由div和div内链接之间的id冲突引起的。所以驱动程序点击了div而不是我想要的链接。 我改变了div id,它正常工作。

之前:

<div id="logout"><a id="logout" href="logoutLink">logout</a></div>

后:

<div id="differentId"><a id="logout" href="logoutLink">logout</a></div>