microsoft / WinAppDriver

Windows Application Driver
MIT License
3.7k stars 1.4k forks source link

Running tests on VM without remote desktop connection #754

Open defaultcqc opened 5 years ago

defaultcqc commented 5 years ago

Hi, I am trying to run the tests on a virtual machine using TFS and Jenkins. Firstly, I revert the virtual machine to a snapshot and then start it through powershell inline scripts commands. Afterwards, I am waiting that Jenkins slave service is up to run the Jenkins pipeline. So, in Jenkins pipeline I start the test execution using VS Test Agent (vstest.console.exe). Tests' DLL for debugging purposes are installed in a snapshot, so I don't have to manipulate with git now and focus on the issue. The issue is - I can't run the tests automatically using TFS and Jenkins without remote desktop connection. I have read a lot of articles considering the possibility of GUI testing on VM and all of them were stating that RDP is necessary for the tests and it is not possible to use winappdriver without it.

What I have already tried: 1) I configured VS test agent on VM to run as an interactive process, but this didn't work. 2) Jenkins was running as a service, I have used task scheduler to run slave node in a command line on user logon but it didn't help, for some reason task scheduler doesn't start the Jenkins slave using command line at user log-in. 3) VM uses auto logon feature, but when I start VM from powershell inline script in TFS right after snapshot revert, Jenkins, as was mentioned above, doesn't create a slave session and doesn't even open a cmd window responsible for a slave node establishment (This window pops up only when I try to connect to RDP).

All in all, I receive the following error in Jenkins Pipeline: Failed to locate opened application window with appId

My question is: is it possible to use WinAppDriver on VM without making any RDP connections and without using UltraVNC? If it is possible, please, provide a detailed guideline of how it is possible to perform the test on VM using TFS and Jenkins. Thank you in advantage.

hassanuz commented 5 years ago

My question is: is it possible to use WinAppDriver on VM without making any RDP connections and without using UltraVNC? If it is possible, please, provide a detailed guideline of how it is possible to perform the test on VM using TFS and Jenkins.

It is possible, but I've only tested this on Azure DevOps. On DevOps you don't have to set up or connect to an RDP for the UI Tests to work assuming the agent had been initially set as Interactive Mode with auto sign-in enabled. We have a bit of documentation on getting set-up with CI in DevOps here.

But if you were to sign-in via RDP, then you would have to disconnect the RDP via tscon, otherwise the machine would be locked out and UI tests won't be able to run.

Again, haven't tested this on Jenkins, so I welcome input from anyone that has! Also if anyone has a guide or documentation they'd like to submit for running on CI via Jenkins that would be most welcomed as well. I imagine the scenario would be similar.

OhAye commented 5 years ago

+1 for the Jenkins integration. It's something that I'll be looking into as well quite soon.

maximojoexpress commented 5 years ago

It's possible. SmartBear have already figured this out. The instructions are not specific to TestComplete though. See below and the page in general https://support.smartbear.com/testcomplete/docs/testing-with/running/via-rdp/overview.html#Workarounds2

Saif4 commented 5 years ago

My question is: is it possible to use WinAppDriver on VM without making any RDP connections and without using UltraVNC? If it is possible, please, provide a detailed guideline of how it is possible to perform the test on VM using TFS and Jenkins.

It is possible, but I've only tested this on Azure DevOps. On DevOps you don't have to set up or connect to an RDP for the UI Tests to work assuming the agent had been initially set as Interactive Mode with auto sign-in enabled. We have a bit of documentation on getting set-up with CI in DevOps here.

But if you were to sign-in via RDP, then you would have to disconnect the RDP via tscon, otherwise the machine would be locked out and UI tests won't be able to run.

Again, haven't tested this on Jenkins, so I welcome input from anyone that has! Also if anyone has a guide or documentation they'd like to submit for running on CI via Jenkins that would be most welcomed as well. I imagine the scenario would be similar.

Yes this I have tried but i still need the screen to be enabled so the tests can run. Im looking for a solution that does not involve screen/monitor, basically headless. Is that possible? @hassanuz

smilinrobin commented 3 years ago

@Saif4 - We were able to configure WAD on JENKINS using instructions here : https://github.com/microsoft/WinAppDriver/pull/1368

dimag25 commented 2 years ago

Hello @smilinrobin I have issue to run winappdriver clicks after I get the driver object I tried your solution.

details:

error {"status":13,"value":{"error":"unknown error","message":"An unknown error occurred in the remote end while processing the command."}}

I'm trying to perform an install on .msi installation via the GUI remotely on azure windows 10 vm. I've tried all the solutions from the post but I have the following error when I'm trying to perform clicks on the windows application.

the problem when I'm running in the CI server(Jenkins Linux server) im not able to open the RDP connection and it not works, if im opening the vm by myself via rdp connection , error not appears and it works flawlessly.

tried the following solutions: https://community.helpsystems.com/kb-nav/kb-article/?id=548d72cc-68c3-eb11-bacc-000d3a1fe4c0&redirect=false https://dev.to/beanworks/the-painful-parts-of-end-to-end-test-automation-for-your-windows-application-1dde

tried also: Psexec - to start the server on the remote machine console Autologon - to unlock the machine on startup

any suggestions and help?