在Firefox中,Selenium“Element is not clickable at point”错误但在Chrome中工作

时间:2016-04-22 12:38:26

标签: selenium firefox selenium-webdriver

在Selenium中我试图找到一个元素。 但得到以下错误:

org.openqa.selenium.WebDriverException: Element is not clickable at point (1009.25, 448.183349609375). Other element would receive the click: <rect data-sdf-index="7" height="390" width="420" class="aw-relations-noeditable-area"></rect> (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 12 milliseconds

firefox中收到此错误。但它在Chrome浏览器中成功运行。 有人有解决方案吗?

我已经尝试过这篇文章的帮助: - Selenium "Element is not clickable at point" error in Firefox但无法获得结果。

我写了以下代码:

public void createPortOnSelectedNode( String nodeName ) {
    ISingleLocator m_nodeContainer = m_nodePage.getNodeContainer();
    WebElement node = m_nodePage.getNode( m_nodeContainer, nodeName ).getElement();
    Actions action = new Actions(DefaultDriver.getWebDriver());
    action.moveToElement(node, 40, 0);
    action.click();
    action.perform();
}

2 个答案:

答案 0 :(得分:2)

嗨,上面的错误出现在你的webdriver脚本执行操作的情况下,但你想要进行操作的元素没有在DOM 中正确加载,即它的位置没有在DOM树中修复(另请注意,selenium能够执行其操作因为元素在DOM中可用因此 webdriver只查找DOM内部元素的存在而不是其中的位置DOM)

那么如何克服这个问题

   1.Give time to DOM to properly give positions to its element.

可以通过以下方式实现:

1.Instead of performing operation's directly at the target area try to do some extra/false 
activity with webdriver which will give time for DOM to position all of his elements
2.apply Thread.sleep().
3. also if you are running your test in smaller window size then set the size to maximum it 
will also help

我没有包含任何代码,因为你在问题中引用的链接包含了大量的工作,所以我决定让每个人都低估为什么会出现这个错误。谢谢希望这有帮助

答案 1 :(得分:0)

您是否尝试过使用Javascript直接点击?在python中我使用

driver.execute_script("arguments[0].click();", elt)

在Java中,它应该看起来像executeScript而不是......