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

完整的错误信息如下:

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

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

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


当前回答

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

结果一切都很顺利

其他回答

这是由以下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));

然后单击元素。

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

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

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

有趣的是,我花了这么多时间研究各种各样的答案,没有人尝试过显而易见的答案,当然,我也没有。如果您的页面多次使用相同的id,就像我的页面一样("newButton",),而您想要的id不是第一个找到的,那么您很可能会得到这个错误。最简单的事情(c#):

var testIt = driver.FindElements(By.Id("newButton"));

注意它是FindElements,而不是FindElement。

然后测试从检索中得到了多少结果。如果是第二个,你可以使用:

testit[1].Click();

或者让那些重复使用id的人来修复它们。

我得到这个bug是因为我测试了一个悬停,然后需要点击工具提示下面的链接。解决方案是添加page.find('.sp-logo')。鼠标悬停在click_link之前以获得工具提示。