title: org.openqa.selenium.NoAlertPresentException: no alert open while invoking Actions class method sendKeys through Selenium
body: <p>EDIT: I found the solution. You can't use the right click in Selenium with the native context menu, only custom context menus</p>
  
  <p>Updating the code to right click on a custom context menu, it worked fine.</p>
  
  <p>I have looked at a dozen solutions and none of them work, so I have to share my code. Note, this solution works on my Mac. It does not work on my work laptop (Windows). I am using Chrome, Java 8, and Selenium 3.8.1</p>
  
  <pre class="lang-java prettyprint-override"><code>@Test
  public void contextClickTest() {
      WebElement contextRegion;
  
      // Arbitrary collection of Keys to execute to navigate context menu
      Keys[] keys = { Keys.ARROW_DOWN, Keys.ENTER };
  
      // this site has a good context click demo
      driver.get("https://swisnl.github.io/jQuery-contextMenu/demo.html");
  
      // get the context region of the button using xpath
      contextRegion = driver.findElement(By.xpath("/html/body/div/section/div/div/div/p/span"));
  
      // Perform action to select some value in the context menu
      Actions act = new Actions(driver).moveToElement(contextRegion).contextClick(contextRegion);
      for(CharSequence cs : keys) {
          act = act.sendKeys(cs);
      }
      act.build().perform();
  
      // if successful an alert will appear. 
      // If not, this will throw an exception
      driver.switchTo().alert().accept();
  }
  </code></pre>
  
  <p>What could be the reason for not working when run on a different machine? Do I need to use different Keys for different platforms?</p>
  
  <p>EDIT: This is the exception thrown by failing open the alert window:</p>
  
  <pre><code>    FAILED: contextClickTest
  org.openqa.selenium.NoAlertPresentException: no alert open
    (Session info: chrome=68.0.3440.106)
    (Driver info: chromedriver=2.33.506106 (8a06c39c4582fbfbab6966dbb1c38a9173bfb1a2),platform=Mac OS X 10.12.6 x86_64) (WARNING: The server did not provide any stacktrace information)
  Command duration or timeout: 0 milliseconds
  Build info: version: '3.8.1', revision: '6e95a6684b', time: '2017-12-01T18:33:54.468Z'
  System info: host: 'Seans-MacBook-Pro.local', ip: '10.0.0.104', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.12.6', java.version: '1.8.0_92'
  Driver info: org.openqa.selenium.chrome.ChromeDriver
  Capabilities {acceptSslCerts: true, applicationCacheEnabled: false, browserConnectionEnabled: false, browserName: chrome, chrome: {chromedriverVersion: 2.33.506106 (8a06c39c4582fb..., userDataDir: /var/folders/h7/0637cbz907d...}, cssSelectorsEnabled: true, databaseEnabled: false, handlesAlerts: true, hasTouchScreen: false, javascriptEnabled: true, locationContextEnabled: true, mobileEmulationEnabled: false, nativeEvents: true, networkConnectionEnabled: false, pageLoadStrategy: normal, platform: MAC, platformName: MAC, rotatable: false, setWindowRect: true, takesHeapSnapshot: true, takesScreenshot: true, unexpectedAlertBehaviour: , unhandledPromptBehavior: , version: 68.0.3440.106, webStorageEnabled: true}
  Session ID: d7788e0a9788a597df727cfbaa4a26bd
      at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
      at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
      at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
      at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
      at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:214)
      at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:166)
      at org.openqa.selenium.remote.http.JsonHttpResponseCodec.reconstructValue(JsonHttpResponseCodec.java:40)
      at org.openqa.selenium.remote.http.AbstractHttpResponseCodec.decode(AbstractHttpResponseCodec.java:80)
      at org.openqa.selenium.remote.http.AbstractHttpResponseCodec.decode(AbstractHttpResponseCodec.java:44)
      at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:164)
      at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:83)
      at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:601)
      at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:658)
      at org.openqa.selenium.remote.RemoteWebDriver$RemoteTargetLocator.alert(RemoteWebDriver.java:987)
      at com.revature.testsuites.ContextClickTest.contextClickTest(ContextClickTest.java:40)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:498)
      at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:80)
      at org.testng.internal.Invoker.invokeMethod(Invoker.java:714)
      at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:901)
      at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1231)
      at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:127)
      at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:111)
      at org.testng.TestRunner.privateRun(TestRunner.java:767)
      at org.testng.TestRunner.run(TestRunner.java:617)
      at org.testng.SuiteRunner.runTest(SuiteRunner.java:334)
      at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:329)
      at org.testng.SuiteRunner.privateRun(SuiteRunner.java:291)
      at org.testng.SuiteRunner.run(SuiteRunner.java:240)
      at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
      at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
      at org.testng.TestNG.runSuitesSequentially(TestNG.java:1198)
      at org.testng.TestNG.runSuitesLocally(TestNG.java:1123)
      at org.testng.TestNG.run(TestNG.java:1031)
      at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:114)
      at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:251)
      at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:77)
  </code></pre>