microsoft / WinAppDriver

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

Unable to Use WinAppDriver for UI testing through Azure Devops CI pipeline #1821

Open Faraz012 opened 1 year ago

Faraz012 commented 1 year ago

We are actually trying to launch WinAppDriver and use it to interact with desktop application for UI testing. I am able to access main window of the desktop application but somehow desktop windows child elements are not accessible. We are able to run it in local machine it is working successfully, but when I am running it on agent through Azure Devops CI pipeline it is not working properly. Please suggest any configurations or prerequisites required before using WinAppdriver on Azure Virtual Machine.

anunay1 commented 1 year ago

Have you configured the agent to run in an interactive mode? Also share what is been shown in the console window.

Tree55Topz commented 1 year ago

pretty much what @anunay1 said, this is important as it will not work if the agent is configured as a service. Additionally, you will need to make sure that your VMs are set up correctly. They will need to at least have some sort of host machine and they will need to be configured to be ran while minimized. Can you give some input as to how your VMs are set up?

Faraz012 commented 1 year ago

@Tree55Topz and @anunay1 It worked with interactive agent. Thanks for the help. Although, I am seeing random behavior in UI testing sometimes I am getting following error image

Any Idea what the issue can be?

JanTrnavskyNovanta commented 1 year ago

Hi @Faraz012, It looks like you have similar issue as I reported here https://github.com/microsoft/WinAppDriver/issues/1789 You can read the whole thread but TL;DR;

Running in CI (GH actions in our case, but it should be similar to Azure pipelines) winappdriver was able to locate only title bar elements. I have no idea why but I have found workaround. Do not pass path to app in capabilities. Start app via some library, find native window handle of the app and attach to it. It is not an elegant solution but it works.

Here is sample code that I originally used to demonstrate the issue, now last commit shows the workaround. It is python code but I believe you will be able to rewrite it to language of your choice.

Here is official documentation for attaching to running app https://github.com/microsoft/WinAppDriver/blob/master/Docs/FAQ.md#when-and-how-to-attach-to-an-existing-app-window

I hope it helps you