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

完整的错误信息如下:

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

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

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


当前回答

我有同样的问题,并得到'其他元素将收到点击'错误显示,可见的元素。我发现没有其他解决方案,以触发与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条评论中提出了一个解决方案。 也许这对你有用

我做了一种蛮力点击,它对我有用。

try:
    elem.click()
except:
    print "failed to click"
    size = elem.size
    mid_of_y = int(size["height"])/2
    stepts_to_do_to_left = int(size["width"])
    while stepts_to_do_to_left > 0:
        try:
            print stepts_to_do_to_left, mid_of_y
            action = webdriver.common.action_chains.ActionChains(driver)
            action.move_to_element_with_offset(elem, mid_of_y, stepts_to_do_to_left)
            action.click()
            action.perform()
            print "DONE CLICK"
            break
        except:
            pass

首先,尝试使用最新的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();");

            }

在Visual Studio 2013中,如果你启用BrowserLink -它会在屏幕底部显示一个BrowserLink导航栏。如果你想点击的项目在导航栏后面,它会给出错误。禁用BrowserLink为我解决了这个问题。

我也因为同样的原因被卡了两天,实际上滚动会让它工作,因为可能是数据无法正常加载,这可能会导致同样的错误一次又一次。

我所做的是,我随机向下滚动,一次是(0,-500),然后是(0,400),然后是(0.-600),你可以根据你的使用给出这些滚动值。只要滚动它,你有内容点击。

driver.execute_script("scrollBy(0,-500);")
sleep(5)

driver.execute_script("scrollBy(0,400);")
sleep(5)

driver.execute_script("scrollBy(0,-600);")
sleep(5)

这真的很有效:)