我只在Chrome浏览器中看到这个。
完整的错误信息如下:
“org.openqa.selenium。WebDriverException:元素在点(411,675)不可点击。其他元素会收到点击:……”
“将接收点击”的元素位于相关元素的一侧,而不是在元素的顶部,也没有重叠,也没有在页面上移动。
我试过加一个偏移量,但也不行。该项目在显示的窗口上,不需要滚动。
我只在Chrome浏览器中看到这个。
完整的错误信息如下:
“org.openqa.selenium。WebDriverException:元素在点(411,675)不可点击。其他元素会收到点击:……”
“将接收点击”的元素位于相关元素的一侧,而不是在元素的顶部,也没有重叠,也没有在页面上移动。
我试过加一个偏移量,但也不行。该项目在显示的窗口上,不需要滚动。
当前回答
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")
其他回答
今天我遇到了同样的问题。如果我说我是如何解决问题的,你不会相信我。
通过最大化浏览器大小
是的,这是一个指针问题,意味着浏览器的大小。为此,您只需要手动或通过代码最大化窗口大小。
在Rselenium中,当链接位于顶部窗口边框时,代码多次成功地使用了这种情况。简单的解决方案是使用sendKeysToElement(),如下所示。
if (unlist(webElem$isElementDisplayed())) {
webElem$sendKeysToElement(list(key = "up_arrow")) # Add "up arrow"..
webElem$clickElement() # ... before $clickElement
我遇到了这个问题,它似乎是由(在我的情况下)点击一个元素,弹出一个div在前面点击的元素。我通过在一个大的try catch块中包装我的点击来解决这个问题。
我有同样的问题,并得到'其他元素将收到点击'错误显示,可见的元素。我发现没有其他解决方案,以触发与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();"
);
结果一切都很顺利
而不是
webdriver.findElement(By.id("id1")).click();
试着使用
click(By.id("id1"));
void click(final By byLocator) {
waitFor(new ExpectedCondition<Boolean>() {
@Override
public Boolean apply(WebDriver driver) {
WebElement element = driver.findElement(byLocator);
if (element.isDisplayed()) {
try {
element.click();
return true;
} catch (Exception e) {
e.printStackTrace();
}
}
return false;
}
@Override
public String toString() {
return "Element located " + byLocator + " clicked";
}
});
}