0

无法使用 SafariDriver Selenium 在 Safari 浏览器中打开上下文菜单。获得以下异常:

org.openqa.selenium.WebDriverException: Unknown command:
{"id":"az1mvyq9x4ly","name":"mouseMoveTo","parameters":
{"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, takeScreenshot=true, javascriptEnabled=true, version=5.1.7,cssSelectorsEnabled=true, platform=WINDOWS, secureSsl=true}]
会话 ID: null

4

2 回答 2

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.
于 2016-05-20T06:56:50.720 回答
0

SafariDriver 尚未实现 Actions/Interactions API。请尝试以下 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 选择器。

于 2016-06-10T09:48:58.233 回答