Selecting an item from context menu
See original GitHub issueHi,
I am using Appium on Windows 10. I am testing classical windows application built with .NET. I am trying to select item from context menu that appears after I right-click edit box (through Appium’s java-client). My code and logs are below.
Before I tried Appium I have been experimenting with native Windows functions from User32.dll and I have noticed that once context menu appears I am unable to send click events nor key events to it although I can get the window handle for the menu. I found online that this may have something to do with privileges or “integrity” level of applications (“UIAccess”) but so far I wasn’t able to bypass that. I tried running in elevated mode and changing local security policies.
Also, I was unable to use findElementByAccessibilityId(“177”) which should give me access to “Select All” item in system’s context menu for text box, so I couldn’t use that either (element not found exception).
Am I doing something wrong or is this an issue that needs to be addressed either in documentation or code fixes?
WebElement elem = driver.findElement(By.xpath("/Window/Edit[2]"));
Actions action = new Actions(driver);
action.contextClick(elem).sendKeys(Keys.ARROW_DOWN).sendKeys(Keys.ARROW_DOWN).sendKeys(Keys.ENTER).build().perform();
The action fails and the following is logged to the console (I have replaced machine name, app’s full path etc. with …):
Exception in thread "main" org.openqa.selenium.WebDriverException: An unknown server-side error occurred while processing the command. Original error: [object Object] (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 0 milliseconds
Build info: version: '3.6.0', revision: '6fbf3ec767', time: '2017-09-27T15:28:36.4Z'
System info: host: '...', ip: '...', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_131'
Driver info: io.appium.java_client.windows.WindowsDriver
Capabilities [{app=...\\WindowsFormsApp1.exe, javascriptEnabled=true, platformName=WINDOWS, deviceName=WindowsPC, platform=WINDOWS}]
Session ID: 0c29a348-7dbd-4404-af8b-9cab4525a6cc
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:82)
at org.openqa.selenium.remote.http.AbstractHttpResponseCodec.decode(AbstractHttpResponseCodec.java:45)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:164)
at io.appium.java_client.remote.AppiumCommandExecutor.execute(AppiumCommandExecutor.java:89)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:586)
at io.appium.java_client.DefaultGenericMobileDriver.execute(DefaultGenericMobileDriver.java:42)
at io.appium.java_client.AppiumDriver.execute(AppiumDriver.java:1)
at io.appium.java_client.windows.WindowsDriver.execute(WindowsDriver.java:1)
at org.openqa.selenium.remote.RemoteExecuteMethod.execute(RemoteExecuteMethod.java:35)
at org.openqa.selenium.remote.RemoteKeyboard.sendKeys(RemoteKeyboard.java:38)
at org.openqa.selenium.interactions.SendKeysAction.perform(SendKeysAction.java:53)
at org.openqa.selenium.interactions.CompositeAction.perform(CompositeAction.java:36)
at org.openqa.selenium.interactions.Actions$BuiltAction.perform(Actions.java:641)
...
The Appium server logs this:
[WinAppDriver] [STDOUT]
[WinAppDriver] [STDOUT]
[WinAppDriver] [STDOUT] ==========================================
[WinAppDriver] [STDOUT] POST /wd/hub/session/E5958A79-2AF5-4623-9CAE-2F352BF23BF3/keys HTTP/1.1
[WinAppDriver] [STDOUT] Accept: */*
[WinAppDriver] [STDOUT] Connection: keep-alive
[WinAppDriver] [STDOUT] Content-Length: 17
[WinAppDriver] [STDOUT] Content-Type: application/json
[WinAppDriver] [STDOUT] Host: 127.0.0.1:4736
[WinAppDriver] [STDOUT] User-Agent: appium
[WinAppDriver] [STDOUT]
[WinAppDriver] [STDOUT] {"value":[""]}
[WinAppDriver] [STDOUT] HTTP/1.1 500 Internal Error
[WinAppDriver] [STDOUT] Content-Length: 133
[WinAppDriver] [STDOUT] Content-Type: application/json
[WinAppDriver] [STDOUT]
[WinAppDriver] [STDOUT] {"status":13,"value":{"error":"unknown error","message":"An unknown error occurred in the remote end while processing the command."}}
[MJSONWP] Encountered internal error running command: {"jsonwp":{"status":13,"value":{"error":"unknown error","message":"An unknown error occurred in the remote end while processing the command."}}} ProxyRequestError: Could not proxy command to remote server. Original error: 500 - {"status":13,"value":{"error":"unknown error","message":"An unknown error occurred in the remote end while processing the command."}}
at JWProxy.proxy$ (../../../lib/jsonwp-proxy/proxy.js:152:13)
at tryCatch (...\AppData\Roaming\npm\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:67:40)
at GeneratorFunctionPrototype.invoke [as _invoke] (...\AppData\Roaming\npm\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:315:22)
at GeneratorFunctionPrototype.prototype.(anonymous function) [as throw] (...\AppData\Roaming\npm\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:100:21)
at GeneratorFunctionPrototype.invoke (...\AppData\Roaming\npm\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:136:37)
[HTTP] <-- POST /wd/hub/session/0c29a348-7dbd-4404-af8b-9cab4525a6cc/keys 500 9 ms - 186
Issue Analytics
- State:
- Created 6 years ago
- Comments:7 (4 by maintainers)
Top GitHub Comments
Hi @timotiusmargo
After your suggestion I have modified the code to look like this:
That did the trick! “Select All” from context menu was clicked. Thank you very much for helping out.
To answer your question, the log above is generated when I attempted to insert key events (ARROW_DOWN) with original code that is on the top of this thread. The idea was to show context menu and then move highlight to the next item in the menu by simulating arrow keys.
Anyways, I have all I need now to write my test. Thank you for support!
Thanks for reporting back. Closing ticket.