Hi,
I've started using the WinAppDriver to start testing the windows desktop application CCleaner using the WinAppDriver.
Approximately 50% of the time I get an issue during the launch of the application, and I can't figure out what the problem is. Can anyone see where I'm going wrong? It seems random, sometimes Appium restart fixes it, sometimes not, but I'd like to resolve this so I can start using these tests in a CI process.
Here's the code in question:
public static class Application
{
private const string AppDriverUrl = "http://127.0.0.1:4723/wd/hub";
private const string CCleanerAppId = @"C:\Program Files\CCleaner\CCleaner64.exe";
private static WindowsDriver<WindowsElement> CCleanerSession;
private static void initialiseAppiumDriver()
{
DesiredCapabilities appCapabilities = new DesiredCapabilities();
appCapabilities.SetCapability("app", CCleanerAppId);
appCapabilities.SetCapability("platformName", "Windows");
appCapabilities.SetCapability("deviceName", "WindowsPC");
CCleanerSession = new WindowsDriver<WindowsElement>(new Uri(AppDriverUrl), appCapabilities);
When the Appium session launches, CCleaner starts up, but it feels like either Appium 'loses' its connection to the app, or my CCleanerSession doesn't get created properly. In the code when debuggin the CCleanerSession above is null.
Error from Debug:
An unknown server-side error occurred while processing the command. Original error: [object Object]
at OpenQA.Selenium.Remote.RemoteWebDriver.UnpackAndThrowOnError(Response errorResponse)
at OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String driverCommandToExecute, Dictionary2 parameters)
at OpenQA.Selenium.Remote.RemoteWebDriver.StartSession(ICapabilities desiredCapabilities)
at OpenQA.Selenium.Remote.RemoteWebDriver..ctor(ICommandExecutor commandExecutor, ICapabilities desiredCapabilities)
at OpenQA.Selenium.Appium.AppiumDriver1..ctor(Uri remoteAddress, ICapabilities desiredCapabilities)
at OpenQA.Selenium.Appium.Windows.WindowsDriver`1..ctor(Uri remoteAddress, DesiredCapabilities desiredCapabilities)
at Framework.Application.initialiseAppiumDriver() in C:\Dev\Repos\CC_UI\CCleaner_Framework\Application.cs:line 37
at Framework.Application.Open() in C:\Dev\Repos\CC_UI\CCleaner_Framework\Application.cs:line 27
at CCleanerTests.Specs.TestCase1.Setup() in C:\Dev\Repos\CC_UI\CCleaner.Specs\TestCase1.cs:line 13
In the Appium console I see this:
[HTTP] <-- POST /wd/hub/session 500 5348 ms - 152
[HTTP] --> POST /wd/hub/session {"desiredCapabilities":{"app":"C:\Program Files\CCleaner\CCleaner64.exe","platformName":"Windows","deviceName":"WindowsPC"}}
[debug] [MJSONWP] Calling AppiumDriver.createSession() with args: [{"app":"C:\\Program Files\\CCleaner\\CCleaner64.exe","platformName":"Windows","deviceName":"WindowsPC"},null,null,null,null,null,null,null,null,null,null,null,null]
[Appium] Creating new WindowsDriver session
[Appium] Capabilities:
[Appium] app: 'C:\Program Files\CCleaner\CCleaner64.exe'
[Appium] platformName: 'Windows'
[Appium] deviceName: 'WindowsPC'
[BaseDriver] The following capabilities were provided, but are not recognized by appium: app.
[BaseDriver] Session created with session id: 4ac8329e-8949-41e7-80c9-74998a5f5551
[WinAppDriver] Verifying WinAppDriver is installed with correct checksum
[debug] [WinAppDriver] WinAppDriver changed state to 'starting'
[WinAppDriver] Killing any old WinAppDrivers, running: FOR /F "usebackq tokens=5" %a in (netstat -nao ^| findstr /R /C:"4823 ") do (FOR /F "usebackq" %b in (TASKLIST /FI "PID eq %a" ^| findstr /I winappdriver.exe) do (IF NOT %b=="" TASKKILL /F /PID %a))
[WinAppDriver] No old WinAppDrivers seemed to exist
[WinAppDriver] Spawning winappdriver with: undefined 4823/wd/hub
[WinAppDriver] [STDOUT] Windows Application Driver Beta listening for requests at: http://127.0.0.1:4823/wd/hub
[debug] [WinAppDriver] WinAppDriver changed state to 'online'
[debug] [JSONWP Proxy] Proxying [POST /session] to [POST http://127.0.0.1:4823/wd/hub/session] with body: {"desiredCapabilities":{"app":"C:\Program Files\CCleaner\CCleaner64.exe","platformName":"Windows","deviceName":"WindowsPC"}}
[WinAppDriver] [STDOUT]
[WinAppDriver] [STDOUT] Address 'http://127.0.0.1:4823/wd/hub' is already in use
[WinAppDriver] [STDOUT]
[WinAppDriver] [STDOUT] Press ENTER to exit.
[WinAppDriver] [STDOUT]
[WinAppDriver] [STDOUT]
[WinAppDriver] [STDOUT] ==========================================
[WinAppDriver] [STDOUT] POST /wd/hub/session HTTP/1.1
[WinAppDriver] [STDOUT] Accept: /
[WinAppDriver] [STDOUT] Connection: keep-alive
[WinAppDriver] [STDOUT] Content-Length: 127
[WinAppDriver] [STDOUT] Content-Type: application/json
[WinAppDriver] [STDOUT] Host: 127.0.0.1:4823
[WinAppDriver] [STDOUT] User-Agent: appium
[WinAppDriver] [STDOUT]
[WinAppDriver] [STDOUT] {"desiredCapabilities":{"app":"C:\Program Files\CCleaner\CCleaner64.exe","platformName":"Windows","deviceName":"WindowsPC"}}
[WinAppDriver] [STDOUT] SessionManager - Creating session
[WinAppDriver] [STDOUT] SessionManager - WinAppDriver succeeded loading MitaBroker
[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."}}
[debug] [WinAppDriver] Deleting WinAppDriver session
[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:126:13)
at tryCatch (C:\Users\phil.losty\AppData\Roaming\npm\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:67:40)
at GeneratorFunctionPrototype.invoke as _invoke
at GeneratorFunctionPrototype.prototype.(anonymous function) as throw
at GeneratorFunctionPrototype.invoke (C:\Users\phil.losty\AppData\Roaming\npm\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:136:37)
[HTTP] <-- POST /wd/hub/session 500 5238 ms - 152
Many thanks, sorry if its something obvious I've missed!
Phil