简体   繁体   English

Selenium Webdriver Java:无法通过Chrome中的操作执行点击操作

[英]Selenium Webdriver Java: Unable to perform click operation by Actions in Chrome

I am using Selenium Webdriver(Java) for my Automation. 我将Selenium Webdriver(Java)用于自动化。 For one of my use-case, I need to click based on co-ordinates. 对于我的一个用例,我需要根据坐标单击。 I am using following code to perform this operation: 我正在使用以下代码执行此操作:

Actions act = new Actions(driver);
act.moveByOffset(236, 92).click().perform();    

Above code is working perfectly in Firefox(Gecko driver). 上面的代码在Firefox(Gecko驱动程序)中运行良好。 But with Chrome driver, it is not working. 但是,使用Chrome驱动程序无法正常工作。 Any idea? 任何想法?
Is there any other way to perform this. 还有其他方法可以执行此操作。

I think you can try what Santosh has suggested 我认为您可以尝试Santosh的建议

act.moveByOffset(236, 92).click().build().perform();

However, this should not make much of a difference as the perform() already contains the build action but this might be a workaround for your problem. 但是,这应该没有太大的区别,因为perform()已经包含了构建操作,但这可能是解决问题的方法。

If you can locate the webelement, you can use JavaScript to perform the click this way: 如果可以找到网络元素,则可以使用JavaScript通过这种方式执行单击:

JavaScriptExecutor js = (driver)JavaScriptExecutor;
js.executeScript("arguments[0].click();", element);

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 无法使用 Selenium(Java、Chrome WebDriver)单击按钮 - Unable to click button using Selenium (Java, Chrome WebDriver) Java / Selenium网络驱动程序:无法单击验证码图标 - Java/Selenium webdriver: Unable to click the captcha icon 无法使用Java在Selenium Webdriver中单击弹出按钮 - Unable to click on a popup button in selenium webdriver with java 无法单击 selenium webdriver 中的“按钮”(使用 Java) - Unable to click the 'button' in selenium webdriver (using Java) Selenium WebDriver Java - 如何执行“如果存在,则单击,否则跳过”? - Selenium WebDriver Java - how to perform "if exists, then click, else skip"? 如何使用 Selenium webdriver 执行 Control + Save 操作? - How to perform Control + Save operation with Selenium webdriver? Safari(12.1)Selenium上的Webdriver硬件崩溃click()和actions.clickAndHold([some web element])。perform() - Safari (12.1) Webdriver hard crash on Selenium click() and actions.clickAndHold([some web element]).perform() 无法在Selenium Webdriver(JAVA)中启动Internet Explorer或Chrome - Unable to start Internet Explorer or Chrome in Selenium Webdriver (JAVA) 无法在 java 中为 Chrome 浏览器在 eclipse 中运行 Selenium / WebDriver - Unable to run Selenium / WebDriver in eclipse for Chrome browser in java 无法在新标签Chrome中找到元素-使用Java的Selenium Webdriver - unable to locate element in new tab chrome - Selenium Webdriver with java
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM