0

Unable to open context menu in Safari browser using SafariDriver Selenium. Getting following exceptions:

org.openqa.selenium.WebDriverException: Unknown command:
{"id":"az1mvyq9x4ly","name":"mouseMoveTo","parameters":
{"element":":wdc:1463726481487"}} (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 5 milliseconds
Build info: version: '2.52.0', revision: '4c2593c', time: '2016-02-11 19:06:42' System info: host: 'RVSKCH19LT', ip: '192.168.10.30', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_11'
Driver info: org.openqa.selenium.safari.SafariDriver
Capabilities [{browserName=safari, takesScreenshot=true, javascriptEnabled=true, version=5.1.7, cssSelectorsEnabled=true, platform=WINDOWS, secureSsl=true}]
Session ID: null

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129

2 Answers2

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.
0

Actions/Interactions API is not implemented with SafariDriver yet. Please try with the following JavaScript solution:

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);

Replace SOME_CSS_SELECTOR with the css selector of the element where you want the right click.

Abhishek Swain
  • 1,054
  • 8
  • 28