我只在Chrome浏览器中看到这个。
完整的错误信息如下:
“org.openqa.selenium。WebDriverException:元素在点(411,675)不可点击。其他元素会收到点击:……”
“将接收点击”的元素位于相关元素的一侧,而不是在元素的顶部,也没有重叠,也没有在页面上移动。
我试过加一个偏移量,但也不行。该项目在显示的窗口上,不需要滚动。
我只在Chrome浏览器中看到这个。
完整的错误信息如下:
“org.openqa.selenium。WebDriverException:元素在点(411,675)不可点击。其他元素会收到点击:……”
“将接收点击”的元素位于相关元素的一侧,而不是在元素的顶部,也没有重叠,也没有在页面上移动。
我试过加一个偏移量,但也不行。该项目在显示的窗口上,不需要滚动。
当前回答
在Drupal中使用Selenium时:
// Get element.
$element = $this->driver->getElement('xpath=//input');
// Get screen location.
$location = $element->getLocation();
// To make sure that Chrome correctly handles clicking on the elements
// outside of the screen, we must move the cursor to the element's location.
$this->driver->moveCursor($location['x'], $location['y']);
// Optionally, set some sleep time (0.5 sec in the example below) if your
// elements are visible after some animation.
time_nanosleep(0, 500000000);
// Click on the element.
$element->click();
其他回答
调试"元素在点上不可点击"错误
要处理此错误,请使用此代码向下滚动。
browser.execute_script("window.scrollTo(0, 300);")
在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
这可能会帮助那些正在使用WebdriverIO的人:
function(){
var runInBrowser = function(argument) {
argument.click();
};
var elementToClickOn = browser.$('element');
browser.execute(runInBrowser, elementToClickOn);
}
来源:https://www.intricatecloud.io/2018/11/webdriverio-tips-element-wrapped-in-div-is-not-clickable/
我在硒驱动的Chrome窗口开得太小的情况下见过这种情况。要点击的元素不在视口中,因此正在失败。
这听起来合乎逻辑……真正的用户必须调整窗口大小或滚动,以便能够看到元素,并实际上单击它。
在指示selenium驱动程序适当地设置窗口大小后,这个问题就消失了。这里描述了webdriver API。