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

完整的错误信息如下:

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

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

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


当前回答

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

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

其他回答

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

结果一切都很顺利

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

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

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

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

  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

我在使用clj-webdriver (Selenium的clojure端口)时也遇到了同样的问题。为了方便起见,我只是将前面的解决方案翻译为clojure。你可以在点击之前调用这个函数来避免这个问题。

(defn scrollTo
  "Scrolls to the position of the given css selector if found"
  [q]
  (if (exists? q) 
    (let [ loc (location-once-visible q) jscript (str "window.scrollTo(" (:x loc) "," (:y loc) ")") ] 
      (execute-script jscript))))

显然,这是Chrome驱动二进制文件中“不会修复”错误的结果。

一个对我有效的解决方案(我们的里程可能有所不同)可以在这个谷歌小组讨论中找到,评论#3:

https://groups.google.com/forum/?fromgroups= !主题/ selenium-developer-activity / DsZ5wFN52tc

相关的部分在这里:

从那以后,我通过直接导航到的href来解决这个问题 跨度的父锚。 driver.Navigate () .GoToUrl (driver.FindElement (By.Id (embeddedSpanIdToClick)) .FindElement (By.XPath(“。”)).GetAttribute(“href”));

在我的例子中,我使用的是Python,所以一旦我得到了所需的元素,我就简单地使用

driver.get(ViewElm.get_attribute('href'))

我希望这只工作,但是,如果你试图点击的元素是一个链接…