Automating Test Cases Using C# WinAppDriver

Modified on Tue, 30 Apr 2024 at 05:03 PM

WinAppDriver (Windows Application Driver) is an open-source tool developed by Microsoft to automate testing for Windows desktop applications. It was derived from Appium, an automation framework primarily used for mobile applications. Microsoft expanded its capabilities to include automation support for Windows applications.

Prerequisites


Leveraging algoQA, you can perform the following:

Use case


This use case demonstrates the automation of a Calculator application by integrating algoQA with the TestComplete framework using the Python language. The example showcases an in-sprint automation process, automating the steps of adding two numbers and verifying the sum.

Profiling 

Profiling is creating an offline model of an application under test (AUT), which involves mimicking a UI model of an AUT using nodes, features and UI elements. For more information, see Profiling.


Scraping the UI elements


You can scrape the required UI elements using algoscraper tool. Refer to Scraping the UI Elements using algoScraper Tool article for more details.

Scrape all the required UI elements and download the file which is available in .CSV format. The downloaded spreadsheet contains control name, control, XPath and Page Name. 

Make sure all the page names are same as UI element’s names.

Alternatively you can upload the scraped file and view the automatic node placement associated features and UI elements on the Main Canvas, as shown:


Record the scenarios using Follow Me feature


Follow Me feature is used to record and save the workflow or scenario or use case. Scenario will be saved in the same sequence it has been recorded.


Note: Recording for the Follow Me feature is done in an offline model. It doesn't interact with the live application.


For more information, see Follow Me section in profiling article.


Generate Test cases


After recording the scenarios using Follow Me feature, next step is generating test cases.

Test cases are generated in Gherkin language and are Behavior-driven development (BDD) complaint. 

For more information, see Generate Test cases section in profiling article.

Accessing the Feature File
The following is a platform generated Feature File.


To access Feature File, navigate to the Test case generated folder > select the appropriate folder as shown:

 Upon generating test cases, download the test cases generated under the Test case folder and save it to your local folder to upload it to algoAF to generate scripts.

Editing Object Repository file


The Object Repository file is an Excel document generated by algoScraper during the application scraping process. This file contains a comprehensive list of UI element names and their corresponding locators. If there is a change in an application under test, you can use a different locator type and modify it in Object Repository file and regenerate the test cases.

The Object Repository file includes essential information: the Control Name, displaying all UI elements, and the Control Type, indicating the types of controls linked to the UI elements. For example, if a UI element's control type is a link, then the UI element functions as a hyperlink or clickable link. The Control Identification Type contains the locator type of the UI element, while Control ID comprises the locators used to locate the UI elements. You can add a UI element by clicking on Add button.

To access object repository file by navigating to Main Canvas > More Menu > Edit Object Repository.


Editing Scenarios


This section guides you through the process of editing scenarios and adding features along with their associated UI elements or controls to existing features.

To access the Edit Scenarios feature, navigate to the Main canvas of algoProfiler and select More > Edit Scenarios. Once you are in the Edit Scenario Interface, choose the relevant scenario and click its associated Edit button. This form comprises both the Scenario Form and Scenario Sequence sections. In the Scenario Form section, you can update any required details, and in the Scenario Sequence section, you can expand a feature to update its controls. Along the sequence scenario line item, you can add a new feature to the existing scenario by clicking the plus button. Similarly, in each feature line, you can include controls by clicking on the corresponding plus button for the existing scenario. In this Edit Scenario form, you can rearrange controls through drag and drop functionality or by using the Up and Down buttons.

Upon updating the feature files, generate the test cases, and you can access the updated feature files by navigating to the appropriate Test Case generated folder.

For more information on how to edit scenarios, refer to Managing Test Cases using Edit Scenarios Workflow.


Executing Test Scripts


This section provides you the information on algoAF, which helps you to choose language and automation framework, generate test scripts and understand scripts folder structure.

algoAF is primarily used for generating test scripts, which are sets of instructions or code designed to automate test cases. Its main function is to create test scripts for UI-based functional test automation. These scripts can be generated for various types of applications, including Web Applications, Desktop Applications, Mobile Apps, Hybrid Applications, Robotic Process Automation, and Embedded software. algoAF also supports scripting in multiple languages. 


For more information on how to generate and execute a script, refer to Steps to Generate Scripts in algoAF.


Updating Applications Settings file

Upon generating the scripts successfully, you will able to see the following screen. Click Ok and then click Open Scripts button to view the algoQA generated scripts folder structure.


Scripts generated from algoQA follows a organized folder structure as shown:

 

Enter Application name and ID as shown and save the changes:


Tip: To fetch the Application ID, navigate to Task Manager > Details tab as shown: 

















Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select atleast one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article