Got response with status 500: {"status":13,"value":{"error":"unknown error",

Hi all. I’m brand new to Appium and am trying to automate some tests against a Windows Desktop app. I’m pretty sure I have something wrong in the parameters I’m passing, or the capabilities I’m asking for, but have not been able to work out what bit is wrong. I think I have the latest Appium, the latest WinAppDriver, and am using C# with Appium.WebDriver 4.4.5 from nuget.

Below is the C# code I’m using, and the output from the Appium Server.

I’ve tried using the WinAppDriver.exe by itself, using one of the automated tests that comes with it for starting Notepad, and that worked, so I’m fairly certain that the WinAppDriver side of things is ok

Any thoughts or suggestions on what I might be doing wrong, or how to figure out what I’m doing wrong would be much appreciated.

            var capabilities = new AppiumOptions();
            
            capabilities.AddAdditionalCapability("platformName", "Windows");
            capabilities.AddAdditionalCapability("appium:automationName", "Windows");
            capabilities.AddAdditionalCapability("appium:app", @"C:\Windows\System32\notepad.exe");
            Environment.SetEnvironmentVariable("APPIUM_HOME", @"C:\Users\MPhillips\.appium\node_modules\appium-windows-driver");

            var driver = new WindowsDriver<WindowsElement>(new Uri("http://127.0.0.1:4723"), capabilities);

            Assert.IsNotNull(driver);
            Assert.IsNotNull(driver.SessionId);

            driver.Close();

PS C:\Users\MPhillips> appium
[Appium] Welcome to Appium v2.5.1
[Appium] The autodetected Appium home path: C:\Users\MPhillips\.appium
[Appium] Attempting to load driver windows...
[Appium] Requiring driver at C:\Users\MPhillips\.appium\node_modules\appium-windows-driver\build\index.js
[Appium] WindowsDriver has been successfully loaded in 0.088s
[Appium] Appium REST http interface listener started on http://0.0.0.0:4723
[Appium] You can provide the following URLs in your client code to connect to this server:
[Appium]        http://192.168.1.153:4723/
[Appium]        http://192.168.56.1:4723/
[Appium]        http://127.0.0.1:4723/ (only accessible from the same host)
[Appium]        http://172.21.11.5:4723/
[Appium] Available drivers:
[Appium]   - [email protected] (automationName 'Windows')
[Appium] No plugins have been installed. Use the "appium plugin" command to install the one(s) you want to use.
[HTTP] Request idempotency key: 92098b7c-5028-4e77-823d-0449a1b137da
[HTTP] --> POST /session
[HTTP] {"desiredCapabilities":{"platformName":"Windows","appium:automationName":"Windows","appium:app":"C:\\Windows\\System32\\notepad.exe"},"capabilities":{"firstMatch":[{"platformName":"Windows","appium:automationName":"Windows","appium:app":"C:\\Windows\\System32\\notepad.exe"}]}}
[AppiumDriver@4a3f] Calling AppiumDriver.createSession() with args: [{"platformName":"Windows","appium:automationName":"Windows","appium:app":"C:\\Windows\\System32\\notepad.exe"},null,{"firstMatch":[{"platformName":"Windows","appium:automationName":"Windows","appium:app":"C:\\Windows\\System32\\notepad.exe"}]}]
[AppiumDriver@4a3f] Event 'newSessionRequested' logged at 1711028917102 (13:48:37 GMT+0000 (Greenwich Mean Time))
[Appium] Attempting to find matching driver for automationName 'Windows' and platformName 'Windows'
[Appium] The 'windows' driver was installed and matched caps.
[Appium] Will require it at C:\Users\MPhillips\.appium\node_modules\appium-windows-driver
[Appium] Requiring driver at C:\Users\MPhillips\.appium\node_modules\appium-windows-driver\build\index.js
[AppiumDriver@4a3f] Appium v2.5.1 creating new WindowsDriver (v2.12.18) session
[AppiumDriver@4a3f] Checking BaseDriver versions for Appium and WindowsDriver
[AppiumDriver@4a3f] Appium's BaseDriver version is 9.5.2
[AppiumDriver@4a3f] WindowsDriver's BaseDriver version is 9.5.2
[WindowsDriver@dbcc] Creating session with W3C capabilities: {
[WindowsDriver@dbcc]   "alwaysMatch": {
[WindowsDriver@dbcc]     "platformName": "Windows",
[WindowsDriver@dbcc]     "appium:automationName": "Windows",
[WindowsDriver@dbcc]     "appium:app": "C:\\Windows\\System32\\notepad.exe"
[WindowsDriver@dbcc]   },
[WindowsDriver@dbcc]   "firstMatch": [
[WindowsDriver@dbcc]     {}
[WindowsDriver@dbcc]   ]
[WindowsDriver@dbcc] }
[WindowsDriver@dbcc (9bdd88c3)] Session created with session id: 9bdd88c3-8e89-480d-b82a-e3dbc3793ec5
[WindowsDriver@dbcc (9bdd88c3)] Spawning 'C:\Program Files\Windows Application Driver\WinAppDriver.exe' with args: ["4725/wd/hub"]
[WindowsDriver@dbcc (9bdd88c3)] Matched '/status' to command name 'getStatus'
[WindowsDriver@dbcc (9bdd88c3)] Proxying [GET /status] to [GET http://127.0.0.1:4725/wd/hub/status] with no body
[WindowsDriver@dbcc (9bdd88c3)] connect ECONNREFUSED 127.0.0.1:4725
[WindowsDriver@dbcc (9bdd88c3)] Windows Application Driver listening for requests at: http://127.0.0.1:4725/wd/hub
[WindowsDriver@dbcc (9bdd88c3)] Press ENTER to exit.
[WindowsDriver@dbcc (9bdd88c3)] Matched '/status' to command name 'getStatus'
[WindowsDriver@dbcc (9bdd88c3)] Proxying [GET /status] to [GET http://127.0.0.1:4725/wd/hub/status] with no body
[WindowsDriver@dbcc (9bdd88c3)] ==========================================
[WindowsDriver@dbcc (9bdd88c3)] GET /wd/hub/status HTTP/1.1
[WindowsDriver@dbcc (9bdd88c3)] Accept: application/json, */*
[WindowsDriver@dbcc (9bdd88c3)] Accept-Encoding: gzip, compress, deflate, br
[WindowsDriver@dbcc (9bdd88c3)] Connection: keep-alive
[WindowsDriver@dbcc (9bdd88c3)] Content-Type: application/json; charset=utf-8
[WindowsDriver@dbcc (9bdd88c3)] Host: 127.0.0.1:4725
[WindowsDriver@dbcc (9bdd88c3)] User-Agent: appium
[WindowsDriver@dbcc (9bdd88c3)] Got response with status 500: {"status":13,"value":{"error":"unknown error","message":"An unknown error occurred in the remote end while processing the command."}}
[W3C] Matched W3C error code 'unknown error' to UnknownError
[WindowsDriver@dbcc (9bdd88c3)] HTTP/1.1 500 Internal Error
[WindowsDriver@dbcc (9bdd88c3)] Content-Length: 133
[WindowsDriver@dbcc (9bdd88c3)] Content-Type: application/json
[WindowsDriver@dbcc (9bdd88c3)]
[WindowsDriver@dbcc (9bdd88c3)] {"status":13,"value":{"error":"unknown error","message":"An unknown error occurred in the remote end while processing the command."}}
[WindowsDriver@dbcc (9bdd88c3)] Matched '/status' to command name 'getStatus'
[WindowsDriver@dbcc (9bdd88c3)] Proxying [GET /status] to [GET http://127.0.0.1:4725/wd/hub/status] with no body

I’m thinking that your driver must have this hard coded in it. Maybe it’s out of date? Regardless, you could get around this issue by starting Appium server like this:

appium --base-path /wd/hub

More info here:

Try GitHub - appium/appium-windows-driver: Appium's interface to WindowsAppDriver provided by Microsoft

I think that Appium calls WindowsDriver to service the request, and then WindowsDriver starts WinAppService listening on that :4724/wd/hub URL to do the work.
WindowsDriver then calls /wd/hub/status to get status from WinAppService, but is getting a 500 error back.

The WindowsDriver I installed is (I believe) that one mentioned by mykola

Maybe this is all a WindowsDriver problem, and reading up about it it looks like it’s not well supported. Which I find weird as Appium is supposedly used for a lot of Windows test automation!

[Appium] Available drivers:
[Appium]   - [email protected] (automationName 'Windows')
...
[WindowsDriver@3016 (f3c4efb1)] Session created with session id: f3c4efb1-61a3-44d6-ad52-410a5055f904
[WindowsDriver@3016 (f3c4efb1)] Spawning 'C:\Program Files\Windows Application Driver\WinAppDriver.exe' with args: ["4724/wd/hub"]