Gaurav is a Performance Test Engineer working with BlazeRunner. He is responsible for customer success and support.  Gaurav enjoys helping with scripting, configuration of integration plugins, general BlazeMeter support as well as analyzing scripts from an engineering perspective.

Become a JMeter and Continuous Testing Pro

Start Learning
Slack

Test Your Website Performance NOW! |

arrowPlease enter a URL with http(s)
Jun 16 2021

Testing Windows Applications Using Taurus and Selenium: A Guide

Functional testing desktop applications that use Windows improves code and feature quality by helping prevent bugs and improving agility. This article details the steps involved in testing the legacy Notepad application by using Taurus, and leveraging a Selenium Script.

 

The script goes through opening the notepad application, navigating through different menus and closing the notepad window. We used TestNG (Java) to write the script, but you can use any other language of your choice and achieve the same functionality. Once you have the script, we will use Taurus to execute it.

 

Please note that the article assumes the reader is familiar with the concept of creating a functional test script in Eclipse (or a similar) IDE using Selenium and TestNG

 

Prerequisites

  1. Windows 10 or higher version Windows machine
  2. WinApp Driver (Click here to download)
    • Winapp is a Product of Microsoft. By using this driver, we can automate Windows applications, classic Windows applications, universal Windows applications, and mobile applications. We can use this driver on top of a Selenium library.
    • Once the driver is downloaded, follow the steps detailed in this article to install it.
  3. Maven and the appropriate environment variables
  4. Eclipse (Oxygen 3.a - more recent version are incompatible with TestNG)
    • TestNG Library from Eclipse Marketplace
  5. Windows Development kit (Click here to download)
  6. Notepad.exe

 

Creating & Executing the Functional Test Script

Now that you've successfully installed WinAppDriver, follow the example below to help get you started. This example uses Eclipse and assumes TestNG is already installed in the project library.

 

Step 1: Update pom.xml to add Appium as a dependency

Before writing a test script, we need to add the Appium dependency in the pom.xml file in the Eclipse project.

 

Under the hood, WinAppDriver is nothing more than a REST service, which supports performing commands against a Windows application by leveraging HTTP methods and JSON payloads. However, Appium, an open-source tool for automating desktop and mobile app testing, provides us with a dedicated SDK to simulate commands and actions executed by our application. We can simulate the pressing of a button; or the typing of a text inside a TextBox; etc. This way, we can simulate the most common flow of actions and interactions performed by the user and make sure that everything works as expected.

 

 

  <dependencies>

       <dependency>

       <groupId>io.appium</groupId>

      <artifactId>java-client</artifactId>

       <version>7.3.0</version>

    </dependency>

    

    <dependency>

       <groupId>org.testng</groupId>

       <artifactId>testng</artifactId>

       <version>6.14.3</version>

     </dependency>

    

    <dependency>

       <groupId>org.seleniumhq.selenium</groupId>

       <artifactId>selenium-java</artifactId>

       <version>3.141.59</version>

     </dependency>

  </dependencies>

 

Step 2: Initialize WindowsDriver

To interact with the windows-based application, we will require WinApp Driver. Initialize the WindowsDriver and provide the URL of the Notepad application executable.

 

Create a class file and set the desired capabilities. In this example, we are setting the Platform Name and the Device Name.

 

DesiredCapabilities cap = new DesiredCapabilities();

cap.setCapability("app", "C:\\Windows\\System32\\notepad.exe");

<You need provide the path for application you want to test>

cap.setCapability("platformName", "Windows");

cap.setCapability("deviceName", "WindowsPC");

 



 

driver = new WindowsDriver(new URL("http://127.0.0.1:4723"), cap);

 

Step 3: Confirm the Required Fields for the Application

To create a sequence of actions you desire to test, we need to inspect the elements and identify their individual identifiers. This will enable us to locate them programmatically. For this, we will be leveraging the Inspector application that comes with the Windows Development Kit. 

Navigate to C:\Program Files (x86)\Windows Kits\10\bin\10.0.19041.0\x64 and double click inspect.exe.

 


 

For instance, say you want to test clicking on the Help menu. Locate it as shown in the screenshot above and grab its unique name.

 

Once you identify the unique name of the element, proceed to the next step.

 

Step 4: Define the Test Using Locators

After locating the individual elements by their name,define your desired actions as shown below.

 

In our example, we are going to perform the following actions.

  1. Open Notepad.exe.
  2. Click Help Menu
  3. Navigate to Edit >> Font
  4. Update the Font to Arial and click Ok
  5. Exit the file by closing the Notepad window

 

These actions are defined in different methods as shown below.

 

 

Once the test script is defined, run it using eclipse to verify its functionality. Then, create a JAR file. 

 

Step 5: Create a Taurus YAML Configuration File

We will now be leveraging Taurus to execute the Selenium test. Taurus helps us by hiding the complexities above by use of an automation-friendly wrapper. 

 

In order to execute the test using Taurus, we will need to create a YAML configuration file as below.

 

 

execution:

- executor: selenium

  runner: testng

  concurrency: 1

  ramp-up: 0m

  hold-for: 0s

  scenario: simple-testng-test

 

scenarios:

  simple-testng-test:

      script: Test.java

      additional-classpath:

      - WinAppDriverSample-0.0.1-SNAPSHOT-jar-with-dependencies.jar

reporting:

- report-name: DesktopAppTesting

  test: DesktopAppTesting

  project: Demo

  upload-artifacts: true

  module: blazemeter

modules:

  blazemeter:

    token: <api_key>:<api_secret>

 

Step 6: Test Execution

  1. Start the WinAppDriver.exe application. (C:\Program Files (x86)\Windows Application Driver)
  2. Copy the YAML, JAR and Java source code to a separate folder so that all the related test files are in one location.
  3. Run the test using bzt <sampleyamlfile>.yaml command.

 

 

 

Step 7: Verify Test Execution

After the desktop application test starts, confirm the requests are passing through the WinApp Driver.

 

 

You can see the test execution of your desktop application below.

 

For example, the screenshot below shows the Help menu pop-up.

 

 

Step 8: Analyzing the Test Results in Taurus CLI

After the test execution is complete, you can see the report in Taurus CLI. The report is pretty comprehensive. It provides us with the average response times per each action and indicates any failures.

 

 

As you must have noticed, we have used several different technologies to achieve this - WinApp, Appium and Selenium. Taurus just provided us with a friendly wrapper by hiding all the complexities involved. 

 

To get started with Taurus, the free open-source testing tool, just install and start testing! After running your test, you can upload the file to BlazeMeter for free and enjoy scalability and advanced analytics. Start testing now!

 

   
arrowPlease enter a URL with http(s)

Interested in writing for our Blog?Send us a pitch!