我只在Chrome浏览器中看到这个。
完整的错误信息如下:
“org.openqa.selenium。WebDriverException:元素在点(411,675)不可点击。其他元素会收到点击:……”
“将接收点击”的元素位于相关元素的一侧,而不是在元素的顶部,也没有重叠,也没有在页面上移动。
我试过加一个偏移量,但也不行。该项目在显示的窗口上,不需要滚动。
我只在Chrome浏览器中看到这个。
完整的错误信息如下:
“org.openqa.selenium。WebDriverException:元素在点(411,675)不可点击。其他元素会收到点击:……”
“将接收点击”的元素位于相关元素的一侧,而不是在元素的顶部,也没有重叠,也没有在页面上移动。
我试过加一个偏移量,但也不行。该项目在显示的窗口上,不需要滚动。
当前回答
我遇到这个是因为这个元素上有一个加载对话框。我只是通过在使用this元素之前添加一个等待来解决这个问题。
try {
Thread.sleep((int) (3000));
} catch (InterruptedException e) {
//
e.printStackTrace();
}
希望这对你有所帮助!
其他回答
在我的例子中,它在Firefox中运行正常,但在Chrome中失败了。在Chrome中,在更新Chrome驱动程序版本到最新版本后,该问题得到了修复。
我有同样的问题,并得到'其他元素将收到点击'错误显示,可见的元素。我发现没有其他解决方案,以触发与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
当驱动程序试图点击元素时,如果元素改变了位置,就会发生这种情况(我在IE中也见过这种情况)。驱动程序保留初始位置,但当它真正点击它时,该位置不再指向该元素。顺便说一句,FireFox驱动程序没有这个问题,显然它是通过编程方式“点击”元素的。
无论如何,当你使用动画或简单地动态改变元素的高度(例如$("#foo").height(500))时,就会发生这种情况。你需要确保你只点击高度已经“确定”的元素。我最终得到了这样的代码(c#绑定):
if (!(driver is FirefoxDriver))
{
new WebDriverWait(driver, TimeSpan.FromSeconds(10)).Until(
d => d.FindElement(By.Id(someDynamicDiv)).Size.Height > initialSize);
}
在动画或任何其他你不容易查询的因素的情况下,你可以使用一个“通用”方法,等待元素是静止的:
var prevLocation = new Point(Int32.MinValue, Int32.MinValue);
int stationaryCount = 0;
int desiredStationarySamples = 6; //3 seconds in total since the default interval is 500ms
return new WebDriverWait(driver, timeout).Until(d =>
{
var e = driver.FindElement(By.Id(someId));
if (e.Location == prevLocation)
{
stationaryCount++;
return stationaryCount == desiredStationarySamples;
}
prevLocation = e.Location;
stationaryCount = 0;
return false;
});