Actions Class not working with gecko driver

落花浮王杯 提交于 2019-11-29 01:38:29

Temporary, awful, depressing answer until they fix this is to revert back to the working versions of Selenium and Firefox. Selenium 2.53.0 with Firefox 45.0.2 is still working: https://ftp.mozilla.org/pub/firefox/releases/45.0.2/

I regret not testing against the latest, but at the same time it beats not having any Firefox tests run at all. Not running against Firefox for months on end is unacceptable.

It's a versioning problem. Selenium 3 has no support yet for Actions class driver. You will have to download to a lower version. Version 2.53.1 works fine for me with Firefox

The below works for me on Firefox 52.3.0 ESR and Selenium 3.5.1

public void mouseRightClickAndSelectOption(By locator, By contextMenuOption){
    clickElement(locator);
    String script = "var evt = document.createEvent('MouseEvents');" + "evt.initMouseEvent('contextmenu',true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0,null);" + "arguments[0].dispatchEvent(evt);";

    try {
        ((JavascriptExecutor) driver).executeScript(script, getElement(locator));
    } catch (Exception ignored) {
    }
    clickElement(contextMenuOption);
}


public WebElement getElement(By locator) {
    fluentWait(locator);
    return driver.findElement(locator);
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!