Automating Test Cases Using C# WinAppDriver

Modified on Fri, 30 Aug at 6:56 PM

1. Overview

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.


2. Prerequisites

3. Use case

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


4. 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.

Leveraging algoQA, you can perform the following:

4.1 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:


4.2 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.


4.3 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.


5. 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.


6. 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.

6.1 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 at least one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article