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

完整的错误信息如下:

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

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

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


当前回答

在Rselenium中,当链接位于顶部窗口边框时,代码多次成功地使用了这种情况。简单的解决方案是使用sendKeysToElement(),如下所示。

if (unlist(webElem$isElementDisplayed())) {
    webElem$sendKeysToElement(list(key = "up_arrow"))  # Add "up arrow"..
    webElem$clickElement()  # ... before $clickElement

其他回答

首先,尝试使用最新的Chrome驱动程序,并检查它是否解决了这个问题。

对我来说,这并没有解决问题。但是,到目前为止,下面的解决方案对我来说是有效的。以下是c#代码,但您可以在特定的语言中遵循相同的逻辑。我们要做的是,

步骤1:关注使用Selenium Actions对象的元素,

步骤2:然后点击元素

步骤3:如果有异常,那么我们通过Selenium浏览器驱动程序的“ExecuteScript”方法执行javascript脚本,从而触发元素上的javascript“Click”事件。

你也可以跳过步骤1和2,只尝试步骤3。步骤3本身就可以工作,但我注意到在一个场景中有一些奇怪的行为,在该场景中,尽管步骤3成功地单击了元素,但在单击元素后,在我的代码的其他部分导致了意想不到的行为。

            try
            {
                //Setup the driver and navigate to the web page...
                var driver = new ChromeDriver("folder path to the Chrome driver");
                driver.Navigate().GoToUrl("UrlToThePage");

                //Find the element...
                var element = driver.FindElement(By.Id("elementHtmlId")); 

                //Step 1
                new Actions(driver).MoveToElement(element).Perform();  

                //Step 2
                element.Click();
            }
            catch (Exception)
            {
                //Step 3
                driver.ExecuteScript("document.getElementById('elementHtmlId').click();");

            }

我也遇到了同样的问题,花了好几个小时才找到解决办法。我试着用量角器点击一个长ngGrid底部的单元格。这是我的ngrrid html的快照:

....many rows here..
<!- row in renderedRows ->
   <!- column in renderedColumns ->
   <div ...> <a ngclick="selectRow(row)"...>the test link 100000</a>...
....

所有的点击功能都不能工作。解决方案是在元素的当前范围内使用evaluate:

element(by.cssContainingText("a", "the test link 100000"))
    .evaluate("selectRow(row)")

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

结果一切都很顺利

当您使用分辨率大于1024x768的浏览器时,尝试最大化浏览器。

driver.manage().window().maximize();

我在使用clj-webdriver (Selenium的clojure端口)时也遇到了同样的问题。为了方便起见,我只是将前面的解决方案翻译为clojure。你可以在点击之前调用这个函数来避免这个问题。

(defn scrollTo
  "Scrolls to the position of the given css selector if found"
  [q]
  (if (exists? q) 
    (let [ loc (location-once-visible q) jscript (str "window.scrollTo(" (:x loc) "," (:y loc) ")") ] 
      (execute-script jscript))))