[英]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.