mouse hover is not working in safari ,selenium web driver

六月ゝ 毕业季﹏ 提交于 2019-12-10 15:37:57

问题


I used the Actions to mouse hover in FF and chrome , it is working fine. But the same code is not working in safari. I am using mac OS and selenium webdriver and java.

I tried below code.

 new Actions(driver).moveToElement(element).build().perform();

JS:

String mouseOverScript = "if(document.createEvent){var evObj = document.createEvent('MouseEvents');evObj.initEvent('mouseover', true, false); arguments[0].dispatchEvent(evObj);} else if(document.createEventObject) { arguments[0].fireEvent('onmouseover');}";
                    JavascriptExecutor js = (JavascriptExecutor) driver;
                    js.executeScript(mouseOverScript, element);

It is a show stopper issue. any help is appreciated.


回答1:


Performing mouse hovers requires using WebDriver's Advanced User Interactions API. In the Java language bindings, this is accomplished by the Actions class. Unfortunately, at present, the SafariDriver does not implement the Advanced User Interactions API, so you cannot accomplish this directly. Until it is implemented, you could probably simulate it using JavaScript to fire the events fired my a mouse hover.



来源:https://stackoverflow.com/questions/26655628/mouse-hover-is-not-working-in-safari-selenium-web-driver

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!