Java 元素在点 处不可点击。其他元素将收到点击:
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/38923356/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Element is not clickable at point . Other element would receive the click:
提问by Samantha
I'm trying to click a button on top of the page.I'm using CSS selector and it works perfectly fine when I run it in my local eclipse.But when I try to run it on Jenkins server on my local machine it fails, saying element not clickable. When I saw the screenshot of failed test on Jenkins I see that the header is overlapping the button that I want to click. I have tried almost everything using XPath,CSS,move to element,move mouse. But still can't fix it, Someone please help.
我正在尝试单击页面顶部的按钮。我正在使用 CSS 选择器,当我在本地 eclipse 中运行它时它工作得很好。但是当我尝试在本地机器上的 Jenkins 服务器上运行它时,它失败了,说元素不可点击。当我在 Jenkins 上看到失败测试的屏幕截图时,我看到标题与我想单击的按钮重叠。我已经尝试了几乎所有使用 XPath、CSS、移动到元素、移动鼠标的方法。但是还是不能解决,求大神帮忙。
I'm tring to click on add buttoun
我想点击添加按钮
org.openqa.selenium.WebDriverException: Element is not clickable at point (775.25, 10.166671752929688). Other element would receive the click: <div class="globalHeader-UtilTop"></div>
Command duration or timeout: 69 milliseconds
Build info: version: '2.53.0', revision: '35ae25b1534ae328c771e0856c93e187490ca824', time: '2016-03-15 10:43:46'
System info: host', ip: '', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.7.0_80'
<div class="Componet-intels**strong text**-Container">
<div class="Componet-intels-Container-Header">
<div class="Componet-intels-Container-Content">
<div class="Componet-intels-Container-Content-Row">
<span class="Componet-intels-Item"> Item # </span>
<span class="Componet-intels-Text-Item">
<span class="Componet-intels-Lable-Quantity"> Qty: </span>
<span class="Componet-intels-Text-Quantity">
<span class="Componet-intels-Button">
**<input class="Componet-intelsButtonIcon" type="button" value="Add">**
</span>
</div>
采纳答案by Satish Gupta
Element is not clickable at point (775.25, 10.166671752929688). Other element would receive the click:
元素在点 (775.25, 10.166671752929688) 处不可点击。其他元素将收到点击:
It clearly says, the element we want to click is hidden by some other element div in this case, which would receive the click.
它清楚地表明,在这种情况下,我们要单击的元素被其他元素 div 隐藏,这将接收单击。
I think it is a problem with the UI and the header shouldn't hide the element, but you can try few things :
我认为这是 UI 的问题,标题不应该隐藏元素,但您可以尝试以下几点:
Maximize the window of the browser from webdriver to see if header still hides the element
driver.manage().window().maximize()
Use JavaScript to click element
WebElement element = driver.findElement(By.<locator>); JavascriptExecutor executor = (JavascriptExecutor)driver; executor.executeScript("arguments[0].click()", element)`
从 webdriver 最大化浏览器的窗口,看看 header 是否仍然隐藏元素
driver.manage().window().maximize()
使用 JavaScript 单击元素
WebElement element = driver.findElement(By.<locator>); JavascriptExecutor executor = (JavascriptExecutor)driver; executor.executeScript("arguments[0].click()", element)`
回答by Amit
Im my case, I had to click on a button which would be visible only after a few graphs were loaded and then an ajax image. The below steps helped me to fix the issue:
我的情况是,我必须单击一个按钮,该按钮仅在加载了几个图形然后加载了 ajax 图像后才可见。以下步骤帮助我解决了这个问题:
Identify the
xpath/css
which disappears after ajax call is complete and explicitly wait for it to beinvisible-wait.until(ExpectedConditions.invisibilityOf(element));
One more explicit wait for the button to be
clickable-wait.until(ExpectedConditions.elementToBeClickable(element));
Use javascript to click on the button-
WebElement element = driver.findElement(By.xpath("")); JavascriptExecutor js = (JavascriptExecutor)driver;
js.executeScript("arguments[0].click()", element);
确定
xpath/css
ajax 调用完成后哪个消失并明确等待它invisible-wait.until(ExpectedConditions.invisibilityOf(element));
一个更明确的等待按钮
clickable-wait.until(ExpectedConditions.elementToBeClickable(element));
使用javascript点击按钮-
WebElement element = driver.findElement(By.xpath("")); JavascriptExecutor js = (JavascriptExecutor)driver;
js.executeScript("arguments[0].click()", element);
If still this doesn't work try inserting an implicit wait between step 1 and 2.
如果这仍然不起作用,请尝试在步骤 1 和 2 之间插入一个隐式等待。
回答by Spike
use JavascriptExecutor.:-
使用JavascriptExecutor.:-
WebElement element = driver.findElement(By.<locator>);
JavascriptExecutor executor = (JavascriptExecutor)driver;
executor.executeScript("arguments[0].click()", element)
回答by vijay
I got this error while using Robot Framework and Chrome browser for Salesforce automation , It got solved when I used key press event (Press Keys ${locator} RETURN) instead of 'Click Element' or 'Click Button' keyword.
我在使用 Robot Framework 和 Chrome 浏览器进行 Salesforce 自动化时遇到了这个错误,当我使用按键事件(Press Keys ${locator} RETURN)而不是“Click Element”或“Click Button”关键字时它得到了解决。