简体   繁体   中英

mouse hover is not working in safari ,selenium web driver

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM