UI automation of Windows Desktop based application using TestStack.White framework

There are many ways to automate the Windows Desktop based applications like Windows form/ Win32 applications or newly emerged UWP (Windows universal) applications.

We will be talking about automating Windows desktop/ UWP application using TestStack.White framework in this blog. This blog is kind of similar to the blog that we already covered as a part of the blog: http://mayureshkulkarni-49.blogspot.in/2014/07/automation-of-windows-native.html. With Visual Studio test project one can easily integrate the White extension from NuGet using the Package manager console and use its capability for UI automation of Windows desktop/ UWP applications.

1. Installation:
It can be easily installed using the command:
PM> Install-Package TestStack.White
Once the White libraries are integrated with your test project. You may go ahead with the creating framework as mentioned in my another blog: http://mayureshkulkarni-49.blogspot.in/2017/12/using-behavior-driver-development.html




















2. Element Identification:
Like Selenium WebDriver White library also expects some element identifiers to search and to act upon. One can use UISpy/ Spy++/ Inspect tools which comes as a part of VS and Windows 8.1 + SDK. This tool will help us identify the desktop elements using the identifiers like
- AutomationId,
- Name,
- Class,
- ControlType etc.

Once the elements are identified we can save those under an element repository and use these as and when required while developing the test scripts. Below is the example of finding the elements of the calculator buttons using the tools mentioned above.











3. Scripting and business logic:
Scripts can be either the feature files (if you are following BDD approach) OR the .cs files (using NUnit approach as mentioned in http://mayureshkulkarni-49.blogspot.in/2014/07/automation-of-windows-native.html). The scripts will contain each step in your test cases and will be mapped to a business logic which actually does/ implements that step.

The business logic can be as below for the steps:
1. Launch the Utility
2. Validating the UI

As shown above, the 1st step is to launch the Utility and second step is to validate the utility UI as implemented above using the White library methods. Similarly, all the steps for the test script can be implemented.

4. Execution:
Once the script is ready you can go ahead with debugging and then execution. Debugging can be achieved using the F10, F11 buttons and execution can be achieved using F5 button.



References:
https://github.com/TestStack/White

Comments