无法使用SafariDriver Selenium在Safari浏览器中打开上下文菜单。获得以下例外:
org.openqa.selenium.WebDriverException:未知命令:
{ “ID”: “az1mvyq9x4ly”, “名”: “mouseMoveTo”, “参数”:
{“element”:“:wdc:1463726481487”}}(警告:服务器未提供任何堆栈跟踪信息)
命令持续时间或超时:5毫秒
构建信息:版本:'2.52.0',修订版:'4c2593c',时间:'2016-02-11 19:06:42' 系统信息:主机:'RVSKCH19LT',ip:'192.168.10.30',os.name:'Windows 7',os.arch:'amd64',os.version:'6.1',java.version:'1.8.0_11 “
司机信息:org.openqa.selenium.safari.SafariDriver
功能[{browserName = safari,takesScreenshot = true,javascriptEnabled = true,version = 5.1.7,cssSelectorsEnabled = true,platform = WINDOWS,secureSsl = true}]
会话ID:null
答案 0 :(得分:0)
try this code to resolve your issue.
WebElement obj = driver.findelement(by.xpath(""));
Action act = new Action(driver);
act.contextClick(obj).perform();
share your code review.
答案 1 :(得分:0)
动作/交互API尚未使用SafariDriver实现。 请尝试使用以下JavaScript解决方案:
String script = "var element = document.querySelector('SOME_CSS_SELECTOR');var e = element.ownerDocument.createEvent(\"MouseEvents\"); e.initMouseEvent(\"contextmenu\", true, true, element.ownerDocument.defaultView, 1, 0, 0, 0, 0, false, false, false, false,2, null); element.dispatchEvent(e);";
driver.executeScript(script);
将SOME_CSS_SELECTOR替换为您想要右键单击的元素的css选择器。