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

完整的错误信息如下:

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

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

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


当前回答

可能有很多因素会抛出这个错误。 首先,dom可能会在selenium webdriver捕获元素之后发生变化,或者在捕获元素之前元素中使用的所有java脚本都没有加载成功。 要解决这个问题,我们需要使用javascript等待或ajax等待如下。

wait = new WebDriverWait(driver, 30);
wait.until((ExpectedCondition<Boolean>) wd -> ((JavascriptExecutor) wd).executeScript("return document.readyState").equals("complete"));
        e_driver = new EventFiringWebDriver(driver);

其次,大多数提供软件qa服务的公司的工程师尝试使用java脚本执行器进行单击操作。

如果这也不起作用,那么使用Actions类执行action。

其他回答

今天我遇到了同样的问题。如果我说我是如何解决问题的,你不会相信我。

通过最大化浏览器大小

是的,这是一个指针问题,意味着浏览器的大小。为此,您只需要手动或通过代码最大化窗口大小。

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

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

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

结果一切都很顺利

有趣的是,我花了这么多时间研究各种各样的答案,没有人尝试过显而易见的答案,当然,我也没有。如果您的页面多次使用相同的id,就像我的页面一样("newButton",),而您想要的id不是第一个找到的,那么您很可能会得到这个错误。最简单的事情(c#):

var testIt = driver.FindElements(By.Id("newButton"));

注意它是FindElements,而不是FindElement。

然后测试从检索中得到了多少结果。如果是第二个,你可以使用:

testit[1].Click();

或者让那些重复使用id的人来修复它们。

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

            }