【问题标题】:Selenium Chrome Driver Actions.MoveToElement receiving error "Element is not clickable at point. Other element would receive the click"Selenium Chrome 驱动程序 Actions.MoveToElement 接收错误“元素无法点击。其他元素将收到点击”
【发布时间】:2017-04-13 22:59:08
【问题描述】:

尝试点击时有很多关于此错误的帖子。当我特别不想点击时收到此错误。

我正在尝试 MoveToElement(是的,该元素在屏幕上可见,无需滚动)

我正在测试的网站是以一种覆盖按钮的不可见“代理元素”的方式编写的。它以这种方式编写以允许拖放交互。无论如何,我不能更改网站,我只负责对其进行测试。

场景是:

我找到了元素

IWebElement element= Driver.FindElement(By.id("btn_open"));

我创建一个动作并移动到元素

Actions builder = new Actions(Driver);
builder.MoveToElement(element);
builder.perform();

下一步是定位“代理”元素

  IWebElement element = Driver.SwitchTo().ActiveElement();

然后我将继续我的其余测试。

问题正在执行中,出现“元素不可点击”异常。

我已经能够解决大约 90% 的这些问题,但是这个问题,我被卡住了。

我已经尝试了这么多疯狂的解决方案,任何帮助都会很棒!!!

谢谢

这是输出和堆栈跟踪

Test Name:  Navigation_Detail_Save
Test FullName:  UITest_Navigation.Save
Test Source:    c:\Core\UITests\UITest_Navigation.cs : line 489
Test Outcome:   Failed
Test Duration:  0:00:04.4112176

Result Message: 
Test method UITest_Navigation.Save threw exception: 
System.InvalidOperationException: unknown error: Element is not clickable at point (489, 102). Other element would receive the click: <div class="sw-drag-proxy  ui-draggable-handle sw-active" title="" style="position: absolute; top: 45px; left: 409.781px; height: 23px; width: 72px;"></div>
  (Session info: chrome=54.0.2840.99)
  (Driver info: chromedriver=2.24.417431 (9aea000394714d2fbb20850021f6204f2256b9cf),platform=Windows NT 10.0.14393 x86_64)
Result StackTrace:  
at OpenQA.Selenium.Remote.RemoteWebDriver.UnpackAndThrowOnError(Response errorResponse)
   at OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String driverCommandToExecute, Dictionary`2 parameters)
   at OpenQA.Selenium.Remote.RemoteWebDriver.InternalExecute(String driverCommandToExecute, Dictionary`2 parameters)
   at OpenQA.Selenium.Remote.RemoteMouse.MouseMove(ICoordinates where)
   at OpenQA.Selenium.Interactions.MoveMouseAction.Perform()
   at OpenQA.Selenium.Interactions.CompositeAction.Perform()
   at OpenQA.Selenium.Interactions.Actions.Perform()
   at UITest_Navigation.Save() in c:\Core\UITests\UITest_Navigation.cs:line 509

【问题讨论】:

  • 你能提供导致错误的代码行号和完整的堆栈跟踪吗?我很困惑,因为您的代码没有点击任何内容,但点击时显示错误。
  • 我从测试中添加了堆栈跟踪
  • 是否可以先将鼠标移动到代理元素,然后再移动到按钮? builder.MoveToElement(proxyElement).MoveToElement(button).perform();
  • 我试图移动到 proxyElement,但问题是,当鼠标移到按钮上时,有一个代理元素被移动到位并分配给按钮。所以实际上没有办法到达那里。由于代理元素,我无法移动到元素,由于无法移动到元素,我无法获取代理元素。

标签: selenium selenium-webdriver selenium-chromedriver


【解决方案1】:

前几天我也遇到了同样的问题,用这个方法解决了

        WebDriverWait wait = new WebDriverWait(driver, new TimeSpan(0, 0, 30));
        wait.Until(ExpectedConditions.ElementExists(By.XPath(element)));
        wait.Until(ExpectedConditions.ElementIsVisible(By.XPath(element)));

【讨论】:

    猜你喜欢
    • 2016-06-08
    • 2023-03-19
    • 2018-03-16
    • 2017-04-16
    • 2012-12-10
    • 2021-10-08
    • 2018-10-26
    • 2016-12-19
    • 1970-01-01
    相关资源
    最近更新 更多