I was trying to run this on a machine that isn't connected to a monitor (e.g. its a virtual machine). When a session tries to start and you aren't connected to the computer with a remote desktop connection then an error is produced. If the same code runs and you are connected at the time with a remote desktop connection then there is no error.
My guess would be that windows app driver can't launch an app when a PC is inactive. Below is what the console shows.
I've also reproduced this when code runs and tries to open a new session on my laptop (a non-remote machine) while it's locked (windows key + L).
==========================================
POST /session HTTP/1.1
Accept: application/json, image/png
Connection: Keep-Alive
Content-Length: 124
Content-Type: application/json;charset=utf-8
Host: 127.0.0.1:4723
SessionManager - Creating session
SessionManager - WinAppDriver succeeded loading MitaBroker
HTTP/1.1 500 Internal Error
Content-Length: 133
Content-Type: application/json
{"status":13,"value":{"error":"unknown error","message":"An unknown error occurred in the remote end while processing the command."}}
Please fix this. I feel like this scenario is the only way to really run this tool in an automated way. This will need to be fixed before any VSO integration I would think.
We faced with the same issue on a physical machine when there is not active remote connection. Can propose any workaround until issue is fixed?
The same problem. The tests are executed if session open on remote workstation. The tests are not executed if session closed. We tried to run WinAppDriver.exe as administrator but it doesn't help. Could you advise any workaround until issue is fixed?
Currently what I do is have a computer under my desk always on. This computer always has a remote desktop connected and I turn off lockscreen.
Hi @quincycs yes this is important to VSTS integration and we are investigating how to enable running WinAppDriver in such a scenario.
assigning issue to myself, will update when there is progress to report.
Hi Yosef,
I'm facing the same issue and its really critical as I've proposed and used this to automate the desktops apps in my organization. I have integrated my tests with teamcity. But, the test only runs if I'm logged into the agent machine and keep my session active. Would be of great help if you can resolve the same, soon.
Thanks,
Francis
Hi Yodurr, any progress on this issue?
Thanks!
Hi @yodurr
Sorry to bother. Do we have any thing to share an update on resolving this issue?
Do you think we can an additional layer between the actual windows desktop and the WinAppDriver.
This layer will be mirroring the actual windows desktop applications and when we try to get a desktop object or any application object WinAppDriver will be able to control the contents of this mirrored layer.
After the operation is finished the actual Windows desktop application will be updated with real content of the mirrored layer.
Does that make sense?
Regards
PD
Hey @quincycs
I was able to try below solution when screen is minimized or closed
Added a DWord ""RemoteDesktop_SuppressWhenMinimized"" with Value 2 at below location
HKEY_LOCAL_MACHINESOFTWAREMicrosoftTerminal Server Client
refer below screenshot
Add this in the Desktop machine from where you have started the RDP session and not in VM

but its not working when I closed the RDP session.
Hi @dhapolapankaj mirroring isn't something we plan on supporting right now. You need to maintain an interactive session, which is why the RDP session needs to stay up during the test.
We run Win10 UWP UI test on virtual machine.
To avoid app "hang" when close RDP session we use command script logout-rdp.bat.
Create a shortcut for it and run as administrator when want to logout from the virtual machine
for /f "skip=1 tokens=3" %%s in ('query user %USERNAME%') do (
%windir%\System32\tscon.exe %%s /dest:console
C:\Install\QRes.exe /x 1920 /y 1080
)
If you need resolution other than default you your IT should manage virtual machine Display settings to allow the required resolutions.
I also used VNC server to manage the resolution of 0-console session as we have to support different resolution testing.
See more details on https://support.smartbear.com/testcomplete/docs/testing-with/running/via-rdp/keeping-computer-unlocked.html
@yodurr Is there any update on this issue. I want to integrate my UWP app tests written using WinAppDriver to VSO. Currently I have to keep the remote desktop window open.
Anybody here?
Any updates on this blocker?
Hi guys, did you found any workaround for this issue?
Hi @DoCode, @rameghwa, @dominik1776,
We recommend the agent to be setup as Interactive so that RDP isn't necessary. We're actively working on documentation to address these issues.
Hi, I'm working on a new project that involves AWS as part of the tested product.
It appears that Amazon do not provide any access other than RDP, so I currently unable to automate our native app in the cloud.
Selenium offers solution called "headless browser" I wonder if such solution can be implemented in WinApp driver.
Hi guys!
Did you find any workaround for this issue? It is very important(
Hi all,
Has anyone managed to get this working?
I've tried running WinAppDriver as a service and making that service interactive but this still doesn't solve the issue.
Thanks,
Ben
Hi @hassanuz,
We need to make some decisions about whether to invest a lot of development effort into using WinAppdriver, but it is blocked by this issue. can you give us an update on the following points?
You say :
We recommend the agent to be setup as Interactive so that RDP isn't necessary
Can you expand on this? Our requirement is simple, we just want to run some UI automation in a build without having to sit watching it. Any suggestions would help.
Also, when you say you are:
working on documentation to address these issues
Does that mean, documenting workaround approaches we can use, or documenting how you aim to fix it in future releases?
Thanks!
Hello all,
There is a workaround with RDP and .bat files for a CI build, until the WinAppDriver team produce a working solution:
I have written a method that gets run before the unit tests begin (i.e. @BeforeClass in Java), executing a .bat file to start remote desktop from the CI build server, which in turn would trigger another .bat file to start WinAppDriver. After the unit tests have run, there is another method (i.e. @AfterClass), executing a .bat file to terminate the RDP session and in turn stop the WinAppDriver from running.
Let me know if you have any questions concerning this.
Kind regards,
Ahmed
@amea20
Can you share the solution you are talking about?
Hello,
I have 4 batch files and 1 rdp file used:
startRemoteDesktop.bat: mstsc.exe C:............remoteMachine.rdp
stopRemoteDesktop.bat: taskkill /F /IM mstsc.exe
startWinAppDriver.bat: start /min "" "C:Program Files (x86)Windows Application DriverWinAppDriver.exe"
stopWinAppDriver.bat: taskkill /F /IM WinAppDriver.exe
I am running a UI automation build on Jenkins, and the unit tests being run contain 2 methods to run before and after the tests begin.
@BeforeClass - The method under this annotation executes startRemoteDesktop.bat stored in the CI server, which runs a stored RDP file into the remote UI automation machine. This triggers a windows Task Scheduler in the remote machine to run startWinAppDriver.bat
@AfterClass - The method under this annotation executes stopRemoteDesktop.bat stored in the CI server. This triggers a windows Task Scheduler in the remote machine to run stopWinAppDriver.bat
This only works if you have the ability to run those commands before and after running the unit tests.
Good luck!!
Ahmed
Thanks for posting this @amea20. This would be awesome to add to the Wiki - would it be alright with you if we add it to the wiki?
Hello @hassanuz
Sure, I have no problem with that. I have added it here to ensure anyone who has struggled with finding a solution can use this until something more stable can be applied.
Kind regards,
Ahmed
hi Ahmed,@amea20 ,
I have installed Jenkins on the same machine on which i trigger nightly build. If i run my TestSuite on the same machine through eclipse, it works fine. But through Jenkins same Test Suite is not getting executed i am getting error ..
An unknown server-side error occurred while processing the command. Original error: Could not proxy command to remote server. Original error: 500 - {"status":13,"value":{"error":"unknown error","message":"The system cannot find the file specified"}} (WARNING: The server did not provide any stacktrace information)
I tried to follow your solution but i could not understand following commands would be applicable in my scenario.
startRemoteDesktop.bat: mstsc.exe C:............remoteMachine.rdp
stopRemoteDesktop.bat: taskkill /F /IM mstsc.exe
If yes, then can you pls help me to understand i should i proceed ahead.
Thanks in Advance..
Hi @jsingh-qualitrol,
Please clarify if you have jenkins setup on one machine, and your target desktop application in another.
The steps below are required:
1) @BeforeClass method executes startRDP.bat to start the RDP session into the remote desktop application server
2) A task scheduler created in the remote machine then triggers startWinAppDriver, with a timeout set to allow WinAppDriver to run before the tests begin
3) @AfterClass method executes stopRDP.bat to terminate the RDP session.
4) Another task scheduler created in the remote machine which triggers stopWinAppDriver, to terminate the WinAppDriver when disconnected from the remote machine.
Refer to comment https://github.com/Microsoft/WinAppDriver/issues/147#issuecomment-395693379 for clarity on the bat files.
Hi Ahmed @amea20
Thanks for reply!!
My jenkins setup and target desktop application are on the same machine.
On the same machine when i run the scripts on eclipse it works and when try to run on Jenkins it fails.
Hence, i think RDP would be required?
Well here is what I did.
We run our automation tests from temporary unix machines that are alive only when the tests runs.
So the problem was that basically there was no session and winappdriver didn鈥檛 recognize any UI, the solution then was easy, to create a session.
I used xfreerdp and connect to the windows machine before the test and vee-OH-la, everything works as expected.
Hi @jsingh-qualitrol,
My workaround was focused on a Windows application that is running on a remote machine which is not the same server as Jenkins. If you are trying to run the application, in your case RDP is not necessary.
Hi
Has anyone had work around for having Jenkins and application running from same machine?
I am blocked by this?
I created feature request for Azure Devops to natively support Hosted agents to be able to run WinAppDriver UI Tests.
You can vote for it here: https://developercommunity.visualstudio.com/idea/369420/winappdriver-for-ui-tests-on-azure-devops-hosted-a.html
It would be great if this took some traction, so share it please :)
Hello,
I have 4 batch files and 1 rdp file used:
startRemoteDesktop.bat: mstsc.exe C:............remoteMachine.rdp
stopRemoteDesktop.bat: taskkill /F /IM mstsc.exe
startWinAppDriver.bat: start /min "" "C:Program Files (x86)Windows Application DriverWinAppDriver.exe" 4723/wd/hub
stopWinAppDriver.bat: taskkill /F /IM WinAppDriver.exeI am running a UI automation build on Jenkins, and the unit tests being run contain 2 methods to run before and after the tests begin.
@BeforeClass - The method under this annotation executes startRemoteDesktop.bat stored in the CI server, which runs a stored RDP file into the remote UI automation machine. This triggers a windows Task Scheduler in the remote machine to run startWinAppDriver.bat
@afterclass - The method under this annotation executes stopRemoteDesktop.bat stored in the CI server. This triggers a windows Task Scheduler in the remote machine to run stopWinAppDriver.bat
This only works if you have the ability to run those commands before and after running the unit tests.
Good luck!!
Ahmed
Currently using this workaround is doing fine, but still hoping WinAppDriver could come up with a more elegant solution.
+1 on the need for this and most importantly to document this limitation on the WinAppDriver project page. We are totally blocked by the inability to run this headless. We currently run TFS and have a TFS Release setup to test our mobile applications on iOS, Android, and Windows. Unfortunately Windows tests fail when trying to run them on a locked desktop.
+1 we need this feature for continuous integration for Xamarin apps
@amea20
Hi,
Refer to comment #147 (comment) for clarity on the bat files.
Is this solution works when we are working with VSTS or AzureDevOps in VM with private agent?
Hello,
I have 4 batch files and 1 rdp file used:
startRemoteDesktop.bat: mstsc.exe C:............remoteMachine.rdp
stopRemoteDesktop.bat: taskkill /F /IM mstsc.exe
startWinAppDriver.bat: start /min "" "C:Program Files (x86)Windows Application DriverWinAppDriver.exe" 4723/wd/hub
stopWinAppDriver.bat: taskkill /F /IM WinAppDriver.exe
I am running a UI automation build on Jenkins, and the unit tests being run contain 2 methods to run before and after the tests begin.
@BeforeClass - The method under this annotation executes startRemoteDesktop.bat stored in the CI server, which runs a stored RDP file into the remote UI automation machine. This triggers a windows Task Scheduler in the remote machine to run startWinAppDriver.bat
@afterclass - The method under this annotation executes stopRemoteDesktop.bat stored in the CI server. This triggers a windows Task Scheduler in the remote machine to run stopWinAppDriver.bat
This only works if you have the ability to run those commands before and after running the unit tests.
Good luck!!
AhmedCurrently using this workaround is doing fine, but still hoping WinAppDriver could come up with a more elegant solution.
Is it running in same machine or different machine?
Hi Guys,
@hassanuz, when you say:
We recommend the agent to be setup as Interactive so that RDP isn't necessary.
Do you mean that if I configure an interactive Azure Pipelines agent, I don't actually need to connect to it using RDP, therefore there is no need for an actual screen/monitor displaying this agent?
If this is true, it is awesome!
@amea20, @weitony111,
I would love to get your feedback on this as well.
Would be great to get some documentation on how to set up automated tests using WinApp driver, - really struggling on this and it just means UWP is falling behind Android and iOS that I already have this set up with Xamarin TestCloud
Is there any update on the issue?
Hi All,
Do we have any update for running Winapp driver test cases on headless mode?. Our Requirement is to run test cases on Windows server 2016 machine through VSTS CI/CD process and mainly headless mode.
I'm using Java language.
Do we have this option?
I solved this problem using two MS Sysinternals utilities:
RDP locks the console - don't forget to reboot when you're done.
To prevent the problem that RDP locks the console when closing the session: we are using pretty much the following command mentioned in this blog/documentation to close a RDP session: https://support.smartbear.com/testcomplete/docs/testing-with/running/via-rdp/keeping-computer-unlocked.html
Hi everyone,
I'm also having an issue with running WinAppDriver tests when using a headless RDP connection. Hopefully, someone has a workaround for this case...
Setup
The Issue
It seems like WinAppDriver could access the GUI with this setup, however, tests still fail on what seems to be a focus or UI accessibility issue. The attached screenshot was captured with this setup and shows the issue. Normally, the screenshot would only capture the application under test. In this case, the whole desktop was captured(?)
Notes
Thanks,
Yuval

@jakubsuchybio Ok so that installs / starts the winapp driver.
What about installing the UWP app and running nunit tests (Xamarin UI Tests)
I got the error:
Deployment Add operation rejected on package MyApp_2.65.0.0_neutral_~_7axyqey0s87sr from:
MyApp_2.65.0.0_x86_x64_AppStore.appxbundle install request because the Local System account is not
allowed to perform this operation.
I'm sure this is to do with the user the build agent is running under, but if I change this then next update the build agent sets it back anway.
Has anyone got any instructions on how to set up an automated ui test using the WinAppDriver pipeline extension? A blog post or wiki outlining the following would be great
Step 1: start winapp driver
step 2: install uwp app
step 3: run nunit ui tests
step 4. uninstsall uwp app
step 5: stop win app driver
@JKennedy24 haven't tried it yet, so dunno
@hassanuz Any update on this issue so far?
Please is there any update on this issue, its critical to run the tests headless without UI @hassanuz
@Saif4, @TanveerDey1 The way WinAppDriver is designed, running UI Tests in a headless state would simply not be possible.
This will require re-engineering WinAppDriver and parts of the Windows UI framework from the ground up which is not feasible at this time.
The limitation for this issue has been a known constraint for (non-web) GUI automation tools for the longest time. I guess due to factors like:
have made this a more popular request. I don't think I've seen as much similar/popular discussions around similar tooling like:
I was able to run tests on Windows apps using a GUI-less RDP connection with QA Wizard (test automation tool). Note that this is different than running the tests without RDP connection at all (like you can do with Web apps).
The advantage of using a GUI-less RDP connection (the RDP task runs in the background) is that you can schedule it to run when the PC is locked. This should be supported by WinAppDriver.
I solved this problem using two MS Sysinternals utilities:
Hi @hepivax,
I am facing the same issue as everyone else here, your solution is interesting. Can you please explain a little bit more.
How are you starting PSExec, from Jenkins ? Do you mind sharing the command to you used to achieve this? My situation is that the Jenkins master is currently hosted on linux and jenkins slave is a windows server 2016 connecting back to jenkins master using a jnlp connection.
I downloaded auto logon and signed in already, not restarted. Since it is a server I don't want to restart multiple times, I am waiting for PSexec setup to be done also and then I can restart the server.
I solved this problem using two MS Sysinternals utilities:
Hi @hepivax,
I am facing the same issue as everyone else here, your solution is interesting. Can you please explain a little bit more.
How are you starting PSExec, from Jenkins ? Do you mind sharing the command to you used to achieve this? My situation is that the Jenkins master is currently hosted on linux and jenkins slave is a windows server 2016 connecting back to jenkins master using a jnlp connection.
I downloaded auto logon and signed in already, not restarted. Since it is a server I don't want to restart multiple times, I am waiting for PSexec setup to be done also and then I can restart the server.
Hi,
I'm not using Jenkins, my both master & slave are Windows machines and I'm using the standard psexec syntax with accept EULA flag.
I don't have experience with running Windows apps on Linux but it should be possible see
https://appdb.winehq.org/objectManager.php?sClass=application&iId=5136
I solved this problem using two MS Sysinternals utilities:
Hi @hepivax,
I am facing the same issue as everyone else here, your solution is interesting. Can you please explain a little bit more.
How are you starting PSExec, from Jenkins ? Do you mind sharing the command to you used to achieve this? My situation is that the Jenkins master is currently hosted on linux and jenkins slave is a windows server 2016 connecting back to jenkins master using a jnlp connection.
I downloaded auto logon and signed in already, not restarted. Since it is a server I don't want to restart multiple times, I am waiting for PSexec setup to be done also and then I can restart the server.Hi,
I'm not using Jenkins, my both master & slave are Windows machines and I'm using the standard psexec syntax with accept EULA flag.
I don't have experience with running Windows apps on Linux but it should be possible see
https://appdb.winehq.org/objectManager.php?sClass=application&iId=5136
@hepivax
Thanks for the quick reply! So what are you using PSExec for? Please provide the command line if possible. I am just trying to work out what PSExec does in your scenario/setup.
@venkatrao-rgare, if you need a PSExec for Linux, have a look at winexe.
Thanks @daluu - looks like i didn't do a good job of asking my question.
So my question is this, what is psexec doing on the Jenkins Slave from Jenkins Master?
In the comment above it mentioned that
Psexec - to start the server on the remote machine console
What does this mean ? Is it starting winappdriver.exe on jenkins slave from jenkins master or is it doing something else .
I am sorry it's not apparent to me from that comment.
Would you be able to help me with this?
Yes, I don't know the details but assume WinAppDriver works (or has a mode that works) like RemoteWebDriver for Selenium, which calls for starting a remote server instance that you can connect to from the driver client (in your test code). Normally, you would have the server prestarted manually and always running on the target remote machine if not start/stop managed by the test framework code. The always running condition could also be configured as a background service/daemon (for windows, linux, etc.) that starts up as part of the OS bootup process.
PSExec mentioned here is simply a way to remotely execute a binary or command on Windows (here in this context being to start up winappdriver server) without first RDP/SSH/telnet into the machine to then execute it (if not using PSExec). But PSExec is Windows to Windows. If you were to execute the command from Linux to Windows, you need WinExe, which does same type of thing.
Now, if the jenkins command runs from jenkins master targeting (remote) slave, in your setup, you would need WinExe since it's linux to Windows. But if the jenkins job command runs directly on the slave as triggered/called by the master, you probably don't even need to use PSExec, because if the slave executes the command locally itself, you just invoke the winappdriver as if its local. But I'm not familiar with the jenkins master/slave execution workflow to know the details.
Thanks聽@daluu聽for your explanation. I've managed to get this working without psexec / winexe for now.I'll leave the way I got this working just in case it is useful to someone else.
I have the same error on remote machine
selenium.common.exceptions.WebDriverException: Message: An unknown error occurred in the remote end while processing the command.
UI tests are running with WinAppDriver in Azure DevOps. I've already read tons of sites including https://github.com/microsoft/WinAppDriver/wiki/WinAppDriver-in-CI-with-Azure-Pipelines
but still don't find a way how to run the GUI session without remote desktop connection.
I created self-hosted agent with Interactive Session (autologon is on), namely:
InteractiveSession | True
USERNAME | ci
SESSIONNAME | Console
-- | --
In pipeline I added cmd task with next commands:
query session
and the answer is:
lw-ci01\ci
SESSIONNAME USERNAME ID STATE TYPE DEVICE
services 0 Disc
> ci 1 Disc
console 3 Conn
31c5ce94259d4... 65536 Listen
rdp-tcp 65537 Listen
So, I don't understand why I still disconnected as ci user?
I'm running into the same issue as above, I have created a gitlab pipeline using a github runner(a VM in azure). Is there any way to make it work without being connected to the RDP to the VM when the tests run? I don't have a master or slave to connect to the VM automatically in GitLab runner.
This is definitely a big issue for anybody how tries to implement testing with winappdriver, it should made more visible.
I solved this problem using two MS Sysinternals utilities:
Thank you very much for this. I wrote a post on your guidance after I got things working. Would love to hear your feedback. I did reference you :) https://dev.to/beanworks/the-painful-parts-of-end-to-end-test-automation-for-your-windows-application-1dde
I solved this issue on GitLab CI/CD implementation using multi projects pipeline like this:
Create a new virtual machine that has an automated task that does an RDP connection to the virtual machine where the tests run.
Make this change to the VM: https://community.helpsystems.com/knowledge-base/automate/general/running-interactive-tasks-in-minimized-remote-desktop-windows/
Set the machine where the RDP connection is made as a Gitlab runner and run the automated task from the .gitlab-ci.yml file.
In another stage start the tests on the other VM where the RDP connection should be up and running.
The second machine(where the tests run) should have autologon it.
I can go into more details if people are interested in this implementation.
I solved this issue on GitLab CI/CD implementation using multi projects pipeline like this:
Create a new virtual machine that has an automated task that does an RDP connection to the virtual machine where the tests run.
Make this change to the VM: https://community.helpsystems.com/knowledge-base/automate/general/running-interactive-tasks-in-minimized-remote-desktop-windows/
Set the machine where the RDP connection is made as a Gitlab runner and run the automated task from the .gitlab-ci.yml file.
In another stage start the tests on the other VM where the RDP connection should be up and running.
The second machine(where the tests run) should have autologon it.
I can go into more details if people are interested in this implementation.
Please, can you share more details about this solution
Thanks
Most helpful comment
Please fix this. I feel like this scenario is the only way to really run this tool in an automated way. This will need to be fixed before any VSO integration I would think.