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

完整的错误信息如下:

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

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

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


当前回答

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

  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

其他回答

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

显然,这是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'))

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

当我试图单击页面上的单选按钮时,我遇到了同样的异常。我使用下面的Javascript并使用IJavaScriptExecutor执行。 c#示例

string script=" function clickCharity() {"+
"var InputElements = document.getElementsByName('Charity');"+
  "for (i=0; i<InputElements.length; i++){"+
    "if(InputElements[i].getAttribute('value') == 'true')"+
    "{"+
        "InputElements[i].click();"+
    "}"+
"}"+
"}";
var js=WebDriver as IJavaScriptExecutor;
js.ExecuteScript(script);

我有另一个bug,在Chrome和Poltergeist上的find_link无法单击一个带有EM标签和一些文本的A标签,尽管它在Firefox和rack_test中工作得很好。解决方案是将click_link(link)替换为:

find('a em', text: link).click

我也遇到了同样的问题,这是由div和div内链接之间的id冲突引起的。所以驱动程序点击了div而不是我想要的链接。 我改变了div id,它正常工作。

之前:

<div id="logout"><a id="logout" href="logoutLink">logout</a></div>

后:

<div id="differentId"><a id="logout" href="logoutLink">logout</a></div>