In this Reqnroll tutorial, you’ll build a Windows Desktop Automation framework using FlaUI, a modern, open-source .NET library for automating Windows desktop applications. It is built on top of Microsoft’s native UI Automation (UIA) framework and acts as a lightweight wrapper it simplifies day-to-day interaction with UI elements, while still giving you access to the underlying UI Automation APIs when you need advanced functionality.
FlaUI supports a wide range of Windows application technologies, including:
Win32
Windows Forms (WinForms)
Windows Presentation Foundation (WPF)
Universal Windows Platform (UWP)
Windows Store applications
Looking to automate a real enterprise desktop application instead of Notepad? See how our desktop app automation testing services can help.
Quick answer: This Reqnroll tutorial shows how to automate a Windows desktop application (Notepad) using FlaUI for UI Automation, Reqnroll for Gherkin-based BDD scenarios, and NUnit as the test runner from project setup through running tests via the command line and viewing an HTML report.
What Is FlaUI?
FlaUI is a free, open-source .NET library for automating Windows desktop applications (Win32, WinForms, WPF, and UWP) by wrapping Microsoft’s UI Automation API in a clean C# interface.
Why Choose FlaUI?
FlaUI stands out for its clean, modern API, its active community support, and its seamless integration with the .NET ecosystem. It works naturally with popular testing frameworks such as NUnit, Reqnroll, xUnit, and MSTest, which means teams can build scalable automation frameworks and plug them straight into CI/CD pipelines.
Unlike older desktop automation tools that rely on additional background services or complicated configuration, FlaUI talks directly to Microsoft’s UI Automation framework. The result is faster execution, better stability, and easier long-term maintenance.
What’s the Difference Between UIA2 and UIA3?
UIA2 is FlaUI’s managed .NET backend for older Win32/WinForms apps, while UIA3 is the newer COM-based backend with better support for WPF and UWP. Use UIA3 by default unless you’re automating a legacy Win32 application.
A unique advantage of FlaUI is that it supports both UIA2 and UIA3, so you can pick whichever automation backend best fits your target application:
UIA2 (UI Automation Version 2) the managed .NET implementation of Microsoft’s UI Automation API. It offers strong compatibility with traditional Win32 and WinForms applications.
UIA3 (UI Automation Version 3) the newer, COM-based implementation. It provides enhanced support for WPF, UWP, and other modern Windows applications, along with better compatibility with newer controls.
If you’ve automated web applications with Selenium or Playwright, you already understand the value of BDD (Behavior Driven Development) and Page Object Models. But desktop applications Notepad, calculators, WPF/WinForms line-of-business tools, legacy Win32 apps don’t have a DOM, and Selenium can’t touch them.
That’s where FlaUI comes in. Combined with Reqnroll (the actively maintained successor to SpecFlow) and NUnit, you get a production-grade framework for automating Windows desktop applications using plain-English Gherkin scenarios.
By the end of this article, you’ll have:
A working Reqnroll + NUnit + FlaUI solution built from a blank Visual Studio project
A feature file written in Gherkin
A Page Object Model class wrapping Notepad
Step definitions that map Gherkin steps to C# code
Hooks that log every step and capture a screenshot on failure
HTML test reports generated automatically
The ability to run everything from the command line using the NUnit console runner
The skills to troubleshoot failures and extend the framework confidently
We’ll use Notepad as the target application throughout this tutorial. It ships with every Windows machine, requires no installation, and is perfect for learning the mechanics of desktop automation without fighting with a complex UI.
Lets you write test scenarios in plain English (Gherkin) that stakeholders can read; actively maintained fork of SpecFlow
2
NUnit
Test runner / assertion framework
Executes the generated test methods and reports pass/fail
3
FlaUI
UI automation library
Wraps Microsoft’s UI Automation API in a clean, fluent C# API to find and interact with desktop controls
1. Prerequisites
Install the following before you start:
Visual Studio Community Edition 2026 (or 2022 instructions are nearly identical) free from visualstudio.microsoft.com
The .NET SDK (latest supported LTS version) verify with the command below
NUnit Console Runner used later to execute tests from the command line. Install via NuGet or download from the NUnit documentation and releases page
FlaUInspect a free inspection tool (similar to Selenium’s “Inspect Element”) that lets you see the AutomationId, Name, ControlType, and ClassName of every control in a desktop application. Download it from the FlaUI GitHub repository releases
dotnet --version
Tip for beginners: Open FlaUInspect, then open Notepad side by side. Click on Notepad’s text area or “File” menu inside FlaUInspect and note the AutomationId values. You’ll need these in Step 4 of this guide.
2. Install the Reqnroll Visual Studio Extension
The Reqnroll extension gives Visual Studio the ability to understand .feature files, provide syntax highlighting, and auto-generate step definition skeletons.
Steps:
Open Visual Studio → Extensions menu → Manage Extensions
In the search box, type “Reqnroll for Visual Studio 2022 & 2026”
Select it from the results and click Install
Restart Visual Studio when prompted to complete installation
Once installed, .feature files will render with proper Gherkin syntax highlighting, and right-clicking a scenario will give you options like “Generate Step Definitions.”
3. Create a Reqnroll NUnit Project
3.1 Create the project
File → New → Project
In the project template search box, type “Reqnroll”
Select Reqnroll Project (NUnit) this scaffolds a project pre-wired for NUnit rather than MSTest or xUnit
3.2 Name your project
Give it a meaningful, lowercase-hyphenated or PascalCase name that reflects its purpose. For this tutorial we’ll use:
qa-test-flaui
3.3 Note the new solution format
Visual Studio 2026 creates solutions using the newer .slnx format (an XML-based replacement for the legacy .sln format). You’ll see:
qa-test-flaui.slnx
This is functionally equivalent to a .sln file all the same commands (dotnet build, dotnet test) work identically. You don’t need to change anything about your workflow.
3.4 Install the required NuGet packages
Open Tools → NuGet Package Manager → Manage NuGet Packages for Solution, or use the Package Manager Console / dotnet add package commands below.
i. Reqnroll packages (BDD framework + NUnit integration)
FlaUI.Core the core desktop automation library (application launching, waits, element trees)
FlaUI.UIA3 the modern UI Automation v3 implementation (use this by default)
FlaUI.UIA2 (optional) only needed if you’re automating older Win32/legacy applications that don’t expose UIA3 properties correctly:
dotnet add package FlaUI.UIA2
After installation, your .csproj should contain a <PackageReference> entry for each package above. Build the project once (Ctrl+Shift+B) to confirm everything restores cleanly before moving on.
4. Folder Structure
Keeping things simple and beginner-friendly, here’s the minimal Reqnroll + FlaUI project structure we’ll build:
This mirrors the same separation of concerns you’d use in a Selenium framework: Features (what), StepDefinitions (glue), Pages (how), Hooks (cross-cutting concerns).
4.1 The Feature File Features/Notepad.feature
Feature files are written in Gherkin: plain English structured into Feature, Scenario, and Given/When/Then steps. Anyone on your team QA, developers, product owners can read this without knowing C#.
Feature: Notepad Text Editing
As a user,
I want to type text and access the File menu
Scenario: Type text into Notepad and verify it appears
Given I launch Notepad
When I type "Hello from Reqnroll and FlaUI!" into the editor
Then I click Page Setup option under File menu
Right-click inside the feature file and choose Generate Step Definitions Reqnroll will scan the steps and offer to scaffold matching method signatures for you.
4.2 The Page Object Model Pages/NotepadWindow.cs
This class is the only place in the entire framework that knows how to interact with Notepad’s UI. If Notepad’s layout changes, or you swap the target app, you only edit this file step definitions stay untouched. Keeping this layer isolated is also what keeps test automation maintenance costs down as your framework grows.
using FlaUI.Core;
using FlaUI.Core.AutomationElements;
using FlaUI.Core.Definitions;
using FlaUI.Core.Tools;
using FlaUI.UIA3;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Application = FlaUI.Core.Application;
namespace Qa_Test_Flaui.Objects.Windows
{
public class NotepadWindow : IDisposable
{
private readonly Application _app;
private readonly UIA3Automation _automation;
private readonly Window _mainWindow;
public NotepadWindow()
{
Process.Start("notepad.exe");
_automation = new UIA3Automation();
_mainWindow = Retry.WhileNull(
() => _automation.GetDesktop()
.FindFirstDescendant(cf => cf.ByName("Untitled - Notepad"))
?.AsWindow(),
TimeSpan.FromSeconds(10))
.Result;
Thread.Sleep(5000);
}
private const string FileTab = "File";
private const string PageSetupSubTab = "Page setup";
private AutomationElement GetEditorElement()
{
Console.WriteLine("---> Get Editor Main Element: " + _mainWindow.Title);
return _mainWindow.FindFirstDescendant(cf => cf.ByName("Text editor"));
}
public void TypeText(string text)
{
var editor = GetEditorElement();
editor.Focus();
editor.AsTextBox().Enter(text);
}
public void OpenPageSetUp()
{
_mainWindow.FindFirstDescendant(
cf => cf.ByName(FileTab)).Click();
Thread.Sleep(2000);
_mainWindow.FindFirstDescendant(
cf => cf.ByName(PageSetupSubTab)).Click();
}
}
}
Step definitions are the glue layer. They parse the Gherkin text, call methods on the Page Object, and make assertions.
using NUnit.Framework;
using Qa_Test_Flaui.Objects.Windows;
using Reqnroll;
namespace qa_test_flaui.StepDefinitions
{
[Binding]
public class NotepadSteps
{
private readonly ScenarioContext _scenarioContext;
private NotepadWindow _notepad;
public NotepadSteps(ScenarioContext scenarioContext)
{
_scenarioContext = scenarioContext;
}
[Given(@"I launch Notepad")]
public void GivenILaunchNotepad()
{
_notepad = new NotepadWindow();
// Store in ScenarioContext so Hooks can access it (e.g., to close it after the scenario)
_scenarioContext["NotepadWindow"] = _notepad;
}
[When(@"I type ""(.*)"" into the editor")]
public void WhenITypeIntoTheEditor(string text)
{
_notepad.TypeText(text);
}
[Then("I click Page Setup option under File menu")]
public void ThenIClickPageSetupOptionUnderFileMenu()
{
_notepad.OpenPageSetUp();
}
}
}
Key things to notice for beginners:
[Binding] tells Reqnroll “this class contains step definitions.”
The regular expressions in [Given], [When], [Then] attributes match the Gherkin text, and (.*) captures the string in quotes as a method parameter.
We store the NotepadWindow instance in ScenarioContext a dictionary-like object that Reqnroll shares across step definitions and hooks within the same scenario. This is how Hooks will later access it to close Notepad automatically.
4.4 Hooks Hooks/Hooks.cs
Hooks handle cross-cutting concerns that shouldn’t clutter your step definitions: logging every step, capturing screenshots on failure, and cleaning up resources.
using FlaUI.Core.Capturing;
using NUnit.Framework;
using Qa_Test_Flaui.Objects.Windows;
using Reqnroll;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Qa_Test_Flaui.Objects.Hooks
{
[Binding]
public class Hooks
{
private readonly ScenarioContext _scenarioContext;
// ThreadLocal prevents log mixing when running tests in parallel
private static readonly ThreadLocal<IReqnrollOutputHelper> _outputHelperContainer = new();
public Hooks(ScenarioContext scenarioContext)
{
_scenarioContext = scenarioContext;
}
[BeforeScenario]
public void BeforeScenario(IReqnrollOutputHelper outputHelper)
{
// Store the current scenario's output helper in the thread container
_outputHelperContainer.Value = outputHelper;
}
[AfterScenario]
public void AfterScenario(IReqnrollOutputHelper outputHelper)
{
// Clear the value after the scenario finishes to prevent memory leaks
_outputHelperContainer.Value = null;
String strPath = TakeScreenshot();
outputHelper.AddAttachment(strPath);
}
/// <summary>
/// Globally accessible method to write logs to the Reqnroll test output.
/// </summary>
public static void AttachStepLog(string message)
{
Console.WriteLine("---> AttachStepLog in...: ");
if (_outputHelperContainer.Value != null)
{
Console.WriteLine("---> AttachStepLog IF in...: " + message);
_outputHelperContainer.Value.WriteLine(message);
}
}
public static string TakeScreenshot()
{
string fullPath = "";
try
{
string projectRoot = AppContext.BaseDirectory.Split(
new[] { $"{Path.DirectorySeparatorChar}bin{Path.DirectorySeparatorChar}" },
StringSplitOptions.None)[0];
string reportFolderLocation = Path.Combine(projectRoot, "Screenshots");
if (!Directory.Exists(reportFolderLocation))
Directory.CreateDirectory(reportFolderLocation);
string fileName = "img-" + DateTime.Now.Ticks + ".png";
fullPath = Path.Combine(reportFolderLocation, fileName);
var bitmap = Capture.Screen();
bitmap.ToFile(fullPath);
}
catch (Exception ex)
{
Console.WriteLine("******* Hooks - Screenshot Exception >>>" + ex.Message);
}
return fullPath;
}
}
}
What’s happening here, step by step:
[BeforeTestRun] runs once before any scenario we use it to ensure the Screenshots folder exists.
[BeforeScenario] and [BeforeStep] log progress to the console (and therefore to the NUnit test output), so when you’re troubleshooting a failure you can see exactly which step the test reached.
[AfterStep] checks _scenarioContext.TestError if a step threw an exception (an assertion failure or an exception from FlaUI), we immediately capture a full-screen screenshot using FlaUI.Core.Capturing.Capture.
TestContext.AddTestAttachment links that screenshot file directly into the NUnit test result, so it shows up when you view results in Test Explorer or in the generated HTML report.
[AfterScenario] disposes of the Notepad process so it doesn’t linger in the background between test runs a common source of “flaky” desktop test suites is leftover processes from previous failed runs.
Reqnroll uses a reqnroll.json file at the project root to control runtime behavior, including generating a Living Documentation-style HTML report after test execution.
You have two common ways to run your tests: through Visual Studio’s Test Explorer (great during development) and through the NUnit Console Runner (essential for CI/CD pipelines and command-line execution).
Build the project first
This command compiles the automation framework and generates the test assembly in the build output folder.
dotnet build
Run tests with the NUnit Console Runner
After the build completes successfully, navigate to the following directory:
Goto to this folder path: ./bin/Debug/net8.0-windows/
nunit3-console.exe qa-test-flaui.dll
The NUnit Console Runner will:
Discover all Reqnroll scenarios.
Execute the automation test suite.
Display the execution progress in the console.
After the test execution completes successfully, the framework automatically generates a Reqnroll HTML Report, providing a detailed overview of the execution.
Need a Production-Ready Desktop Automation Framework?
Open the following file in any web browser to view the execution dashboard:
Troubleshooting checklist
These are the most common issues teams hit when running this Reqnroll and FlaUI test suite for the first time.
Symptom
Likely Cause
Fix
ElementNotAvailableException
Locator (AutomationId/ControlType) is wrong for your Notepad version
Re-inspect with FlaUInspect; Windows 11 Notepad’s control tree differs from older versions
Test hangs indefinitely
FlaUI is waiting for a window that never appeared
Add explicit Retry.WhileNull(…) waits around GetMainWindow; check the app actually launched
Notepad processes pile up after failed runs
AfterScenario hook wasn’t reached due to an unhandled exception before NotepadWindow was stored in ScenarioContext
Wrap window launch in a try/catch, or add a BeforeScenario step that kills any lingering notepad.exe processes first
Screenshot file not found in report
Path mismatch between TestContext.WorkDirectory and the actual output folder
Print ScreenshotDirectory to console at runtime to confirm the exact resolved path
Tests pass locally but fail in CI
CI agent runs “headless” / no interactive desktop session
Desktop UI Automation requires an interactive session configure your CI agent to run as an interactive service or use a self-hosted agent with a real desktop session
8. Inspecting UI Elements Using FlaUInspect
FlaUInspect is a free Windows UI Automation inspector. Use it to find the AutomationId, Name, ControlType, and ClassName of any element before writing a locator.
Run as Administrator and open FlaUInspect.exe. It opens a window with a tree view on the left and a properties panel on the right.
Step to Use Hover Mode:
Click the Hover Mode button in the inspection tool’s toolbar to activate it.
Move your mouse cursor over the application window you want to inspect.
Press and hold the Ctrl key on your keyboard while keeping the mouse hovered over the specific UI element.
Note: Inspect elements like the Window Title or File Menu button as shown below.
Conclusion
This Reqnroll tutorial walked you through building a complete Windows desktop automation framework with FlaUI and NUnit from installing the Reqnroll Visual Studio extension and scaffolding the project, through building a Page Object Model, step definitions, and hooks for Notepad, to running your suite from the command line and reading the generated HTML report. With FlaUInspect in your toolkit for locating elements, you now have everything needed to extend this same pattern to a real, production desktop application.
FlaUI is an open-source .NET library for automating Windows desktop applications Win32, WinForms, WPF, and UWP apps by wrapping Microsoft's native UI Automation (UIA) framework in a cleaner C# API.
Can Selenium automate desktop applications like FlaUI does?
No. Selenium automates browser-based (DOM) applications; it can't interact with native Windows desktop apps. FlaUI fills that gap by talking directly to Microsoft's UI Automation API instead of a browser DOM.
What's the difference between UIA2 and UIA3 in FlaUI?
UIA2 is the managed .NET implementation, best for older Win32/WinForms apps. UIA3 is the newer COM-based implementation with stronger support for WPF, UWP, and modern controls and is FlaUI's recommended default.
How do I find element locators for a desktop app before writing FlaUI code?
Use FlaUInspect, a free inspection tool from the FlaUI project. Hover over any control while holding Ctrl to see its AutomationId, Name, ControlType, and ClassName the values you'll use in your FlaUI locators.
Does FlaUI work with testing frameworks other than Reqnroll and NUnit?
Yes. FlaUI integrates cleanly with xUnit and MSTest as well, so teams can slot it into whatever test runner and CI/CD pipeline they already use.
Desktop Automation Testing continues to play a critical role in modern software quality, especially for organizations that rely heavily on Windows-based applications. While web and mobile automation dominate most conversations, desktop applications still power essential workflows across industries such as banking, healthcare, manufacturing, and enterprise operations. As a result, ensuring their reliability is not optional; it is a necessity. However, testing desktop applications manually is time-consuming, repetitive, and often prone to human error. This is exactly where WinAppDriver steps in.
WinAppDriver, also known as Windows Application Driver, is Microsoft’s automation tool designed specifically for Windows desktop applications. More importantly, it follows the WebDriver protocol, which means teams already familiar with Selenium or Appium can quickly adapt without learning an entirely new approach. In other words, WinAppDriver bridges the gap between traditional desktop testing and modern automation practices.
In this guide, you will learn how to set up WinAppDriver, create sessions, locate elements, handle popups, perform UI actions, and build real automation tests using C#. Whether you are just getting started or looking to strengthen your desktop automation strategy, this guide will walk you through everything step by step.
At its core, WinAppDriver is a UI automation service for Windows applications. It allows testers and developers to simulate real user interactions such as clicking buttons, entering text, navigating windows, and handling dialogs.
What makes it particularly useful is its ability to automate multiple types of Windows applications, including:
Because of this wide support, WinAppDriver fits naturally into enterprise environments where different technologies coexist.
Even better, it follows the same automation philosophy used in Selenium. So instead of reinventing the wheel, you can reuse familiar concepts like:
Driver sessions
Element locators
Actions (click, type, select)
Assertions
This familiarity significantly reduces the learning curve and speeds up adoption.
Why Use WinAppDriver for Desktop Automation Testing?
Before diving into implementation, it is important to understand why WinAppDriver is worth using.
First, it provides a standardized way to automate desktop UI interactions. Without it, teams often rely on manual testing or fragmented tools that are hard to maintain.
Second, it supports multiple programming languages such as:
C#
Java
Python
JavaScript
Ruby
This flexibility allows teams to integrate WinAppDriver into their existing tech stack without disruption.
Additionally, WinAppDriver works well for real-world scenarios. Desktop applications often include:
Multiple windows
Popups and dialogs
Keyboard-driven workflows
System-level interactions
WinAppDriver is built to handle these complexities effectively.
Installing WinAppDriver
Getting started with WinAppDriver is straightforward. First, download the installer:
WindowsApplicationDriver.msi
Once downloaded, follow the standard installation process:
Double-click the installer
Follow the setup wizard
Accept the license agreement
Complete installation
By default, WinAppDriver is installed at:
C:\Program Files (x86)\Windows Application Driver
Before running any tests, make sure to enable Developer Mode in Windows settings. This step is essential and often overlooked.
Launching WinAppDriver
After installation, the next step is to start the WinAppDriver server.
You can launch it manually:
Search for Windows Application Driver in the Start menu
Right-click and select Run as Administrator
Alternatively, you can start it programmatically, which is useful for automation frameworks:
Using a code-based startup ensures consistency and removes manual dependency during test execution.
Creating an Application Session
Once the server is running, you need to create a session to interact with your application.
Here’s a basic example:
AppiumOptions options = new AppiumOptions();
options.AddAdditionalCapability("app", @"C:\notepad.exe");
options.AddAdditionalCapability("deviceName", "WindowsPC");
WindowsDriver<WindowsElement> driver =
new WindowsDriver<WindowsElement>(
new Uri("http://127.0.0.1:4723"), options);
This step is critical because it establishes the connection between your test and the application. Without a valid session, no automation can take place.
Working with Windows and Application State
Desktop applications often involve multiple windows. Therefore, handling window state becomes essential.
For example, you can retrieve the current window title:
Using keyboard actions makes your tests more realistic and closer to actual user behavior.
Creating a Desktop Root Session
Sometimes, you need to interact with the entire desktop instead of a single app.
Here’s how you create a root session:
var options = new AppiumOptions();
options.AddAdditionalCapability("app", "Root");
options.AddAdditionalCapability("deviceName", "WindowsPC");
var session = new WindowsDriver<WindowsElement>(
new Uri("http://127.0.0.1:4723"), options);
This approach is particularly useful for:
File dialogs
System popups
External windows
Required NuGet Packages
Appium.WebDriver
NUnit
NUnit3TestAdapter
Microsoft.NET.Test.Sdk
Complete NUnit Test Example
using NUnit.Framework;
using OpenQA.Selenium.Appium;
using OpenQA.Selenium.Appium.Windows;
using System;
namespace WinAppDriverDemo
{
[TestFixture]
public class NotepadTest
{
private WindowsDriver<WindowsElement> driver;
[SetUp]
public void Setup()
{
AppiumOptions options = new AppiumOptions();
options.AddAdditionalCapability("app", @"C:\Windows\System32\notepad.exe");
options.AddAdditionalCapability("deviceName", "WindowsPC");
driver = new WindowsDriver<WindowsElement>(
new Uri("http://127.0.0.1:4723"),
options);
driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(5);
}
[Test]
public void EnterTextInNotepad()
{
WindowsElement textArea = driver.FindElementByClassName("Edit");
textArea.SendKeys("Hello WinAppDriver Automation");
string title = driver.Title;
Assert.IsTrue(title.Contains("Notepad"));
}
[TearDown]
public void TearDown()
{
driver.Quit();
}
}
}
A ready element is better than a rushed interaction
A dedicated session is better than forcing one session to handle everything
These small decisions significantly reduce flaky tests and improve long-term maintainability.
Conclusion
WinAppDriver provides a powerful yet approachable way to implement Desktop Automation Testing for Windows applications. It combines the familiarity of WebDriver with the flexibility needed for real desktop environments. By following the right setup, using stable locators, handling popups correctly, and structuring tests properly, teams can build reliable automation frameworks that scale over time. Ultimately, success with WinAppDriver is not just about tools it is about building a strategy that prioritizes stability, clarity, and maintainability.
Want to build a reliable WinAppDriver framework for your team? Get expert guidance tailored to your use case.
WinAppDriver is used for Desktop Automation Testing of Windows applications. It allows testers to automate UI interactions such as clicking buttons, entering text, and handling windows in Win32, WPF, and UWP apps.
How does WinAppDriver work?
WinAppDriver works using the WebDriver protocol, similar to Selenium. It creates a session between the test script and the Windows application, allowing automation of user actions like clicks, typing, and navigation.
Which applications can be automated using WinAppDriver?
WinAppDriver supports automation for multiple Windows application types, including:
Win32 applications
WPF (Windows Presentation Foundation) apps
UWP (Universal Windows Platform) apps
This makes it suitable for both legacy and modern desktop applications.
What is the best locator strategy in WinAppDriver?
The most reliable locator strategy in WinAppDriver is AccessibilityId. It provides stable and maintainable element identification. XPath can also be used, but it is less stable and should be avoided when possible.
Can WinAppDriver handle popup windows and dialogs?
Yes, WinAppDriver can handle popup windows by switching between window handles. For system-level dialogs, a Desktop Root Session can be used to interact with elements outside the main application.
Is WinAppDriver similar to Selenium?
Yes, WinAppDriver is similar to Selenium because both use the WebDriver protocol. The main difference is that Selenium automates web browsers, while WinAppDriver automates Windows desktop applications.
Modern software teams are expected to deliver high-quality applications faster than ever. However, as desktop applications become more complex, relying only on manual testing can slow down release cycles and increase the risk of defects. This is where understanding the TestComplete features becomes valuable for QA teams looking to automate their testing processes efficiently. TestComplete, developed by SmartBear, is a powerful automation tool designed to test desktop, web, and mobile applications. It is especially known for its strong desktop testing capabilities, supporting technologies like .NET, WPF, Java, and Delphi. With features such as keyword-driven testing, intelligent object recognition, and multi-language scripting, TestComplete helps teams automate repetitive tests, improve test coverage, and deliver more reliable software releases.
In this guide, we’ll walk through the key TestComplete features, explain how they work, and compare them with other automation tools. By the end, you’ll have a clear understanding of how TestComplete helps QA teams automate desktop applications faster and more reliably.
TestComplete is a functional UI test automation tool created by SmartBear. It allows teams to automate end-to-end tests for:
Desktop applications
Web applications
Mobile applications
QA teams typically use TestComplete for tasks like:
Regression testing
UI validation
Functional testing
End-to-end workflow testing
One of the most attractive aspects of TestComplete is its flexibility in scripting languages. Teams can write automation scripts using:
Python
JavaScript
VBScript
JScript
DelphiScript
C++Script
C# Script
This flexibility makes it easier for teams to integrate TestComplete into existing testing frameworks and workflows.
Key TestComplete Features for Desktop Test Automation
Intelligent Object Recognition
One of the most impressive TestComplete features is its object recognition capability.
Instead of interacting with UI elements based on fragile screen coordinates, TestComplete identifies application components based on their properties and hierarchy.
In simpler terms, the tool understands the structure of the application UI. So even if the layout changes slightly, the automation script can still locate the correct elements.
Why this matters
Without strong object recognition, automation scripts often break when developers update the interface. TestComplete reduces this problem significantly.
Example
Imagine testing a desktop login form.
A coordinate-based test might click on a button like this:
Click (X:220, Y:400)
But if the interface changes, the script fails.
With TestComplete, the script targets the object itself:
Aliases.MyApp.LoginButton.Click()
This approach makes automation far more reliable and easier to maintain.
Keyword-Driven Testing (Scriptless Automation)
Not every tester is comfortable writing code. TestComplete solves this by offering keyword-driven testing.
Instead of writing scripts, testers can create automated tests using visual steps such as:
Click Button
Enter Text
Verify Property
Open Application
These steps are arranged in a structured workflow that defines the automation process.
Why QA teams like this feature
Keyword testing allows manual testers to participate in automation, which helps teams scale their automation efforts faster.
Benefits include:
Faster test creation
Lower learning curve
Better collaboration between testers and developers
Multiple Scripting Language Support
Another major advantage of TestComplete is that it supports multiple scripting languages.
Different teams prefer different languages depending on their technology stack.
S. No
Language
Why Teams Use It
1
Python
Popular for automation frameworks
2
JavaScript
Familiar for many developers
3
VBScript
Common in legacy enterprise environments
4
C# Script
Useful for .NET applications
This flexibility allows organizations to choose the language that best fits their workflow.
Record and Playback Testing
For teams just starting with automation, TestComplete’s record-and-playback feature is extremely helpful.
Here’s how it works:
Start recording a test session
Perform actions in the application
Save the recording
Replay the test whenever needed
The tool automatically converts recorded actions into automation steps.
When is this useful?
Record-and-playback works well for:
Simple regression tests
UI workflows
Quick automation prototypes
However, most mature QA teams combine recorded tests with custom scripts to make them more stable.
Cross-Platform Testing Support
Although TestComplete is widely known for desktop automation, it also supports testing across multiple platforms.
Teams can automate tests for:
Desktop applications
Web applications
Mobile apps
This allows organizations to maintain one centralized automation platform instead of managing multiple tools.
Supported desktop technologies
Windows Forms
WPF
.NET
Java
Delphi
C++
This makes it especially useful for enterprise desktop applications that have been around for years.
Data-Driven Testing
Another powerful feature is data-driven testing, which allows the same test to run with multiple data inputs.
Instead of creating separate tests for each scenario, testers can connect their automation scripts to external data sources.
Common data sources include:
Excel spreadsheets
CSV files
Databases
Built-in data tables
With data-driven testing, one script can validate all these scenarios automatically.
This approach significantly reduces duplicate tests and improves coverage.
Detailed Test Reports and Logs
Understanding why a test failed is just as important as running the test itself.
TestComplete generates detailed execution reports that include:
Test steps performed
Screenshots of failures
Execution time
Error messages
Debug logs
These reports make it easier for QA teams and developers to identify and fix issues quickly.
CI/CD Integration
Modern software teams rely heavily on continuous integration and continuous delivery pipelines.
TestComplete integrates with popular CI/CD tools such as:
Jenkins
Azure DevOps
Git
Bitbucket
TeamCity
This allows automation tests to run automatically during:
Code commits
Build pipelines
Release validation
The result is faster feedback and improved release confidence.
TestComplete is often the preferred choice for teams that need reliable desktop automation and enterprise-level capabilities.
Example: Automating a Desktop Banking System
Consider a QA team working on a desktop banking application.
Before automation, the team manually tested features like:
User login
Transaction processing
Account updates
Report generation
Regression testing took two to three days every release cycle.
After implementing TestComplete:
Login tests were automated using keyword testing.
Transaction workflows were scripted using Python.
Multiple users were tested through data-driven testing.
Tests were integrated with Jenkins pipelines.
Regression testing time dropped from three days to just a few hours.
This allowed the team to release updates faster without sacrificing quality.
Benefits of Using TestComplete
S. No
Benefit
Description
1
Faster Automation
Record and keyword testing speed up automation
2
Lower Maintenance
Smart object recognition reduces broken tests
3
Flexible Scripting
Multiple language support
4
DevOps Friendly
CI/CD integrations available
5
Enterprise Ready
Handles large and complex applications
Best Practices for Using TestComplete
Use object mapping – Organize UI elements in a repository for better test stability.
Combine keyword and scripted tests – Use keyword tests for simple workflows and scripts for complex scenarios.
Implement data-driven testing – Improve test coverage without duplicating scripts.
Integrate with CI/CD – Run automation tests during build pipelines.
Maintain clear reporting – Use logs and screenshots to quickly identify failures.
Conclusion
TestComplete offers a powerful set of features that make desktop test automation faster, more reliable, and easier to scale. With capabilities like intelligent object recognition, keyword-driven testing, multi-language scripting, and CI/CD integration, it helps QA teams automate complex workflows while reducing manual effort. For organizations that rely heavily on Windows desktop applications, TestComplete provides the flexibility and stability needed to build efficient automation frameworks. When implemented with the right testing strategy, it can significantly improve test coverage, speed up regression cycles, and support faster, high-quality software releases.
Looking to improve your desktop test automation with TestComplete? Our QA experts can help you build scalable automation solutions and enhance testing efficiency.
The main TestComplete features include intelligent object recognition, keyword-driven testing, record and playback automation, multi-language scripting, data-driven testing, detailed reporting, and CI/CD integration. These features help QA teams automate testing for desktop, web, and mobile applications efficiently.
Why are TestComplete features useful for desktop test automation?
TestComplete features are especially useful for desktop testing because the tool supports Windows technologies such as .NET, WPF, Java, and Delphi. Its object recognition engine allows testers to interact with UI elements reliably, reducing test failures caused by interface changes.
Does TestComplete require programming knowledge?
No, TestComplete does not always require programming skills. One of the most helpful TestComplete features is keyword-driven testing, which allows testers to create automated tests using visual steps without writing code.
Which programming languages are supported by TestComplete?
One of the flexible TestComplete features is its support for multiple scripting languages. Testers can write automation scripts using Python, JavaScript, VBScript, JScript, DelphiScript, C#Script, and C++Script.
How do TestComplete features support CI/CD testing?
TestComplete integrates with popular CI/CD tools such as Jenkins, Azure DevOps, and Git. These TestComplete features allow automated tests to run during build pipelines, helping teams identify issues early in the development process.
Is TestComplete better than Selenium for desktop testing?
For desktop automation, TestComplete is often considered more suitable because Selenium primarily focuses on web testing. The built-in TestComplete features provide stronger support for desktop UI automation and enterprise applications.
Automation testing helps software teams deliver reliable applications faster. By automating repetitive validation tasks, QA engineers can ensure that applications behave consistently across releases while reducing manual testing effort. However, teams performing TestComplete Remote Desktop testing on remote machines using Remote Desktop Protocol (RDP) often encounter an unexpected problem: automated GUI tests fail when the Remote Desktop session is minimized. This issue frequently affects testers using TestComplete, a powerful automation tool designed for desktop, web, and mobile testing. When running TestComplete automation remotely, engineers may assume that minimizing the Remote Desktop window should not affect the automation process. Unfortunately, Windows behaves differently.
When an RDP session is minimized, Windows automatically stops rendering the graphical interface of the remote machine. This optimization helps reduce resource usage, but it also causes problems for GUI-based automation tools. Since automation frameworks like TestComplete rely on visible UI elements such as buttons, text boxes, menus, and dialog windows, the automation engine can no longer interact with the application interface.
As a result, testers experience issues such as:
UI elements not being detected
Automated clicks failing
Object recognition errors
Tests stopping unexpectedly
For QA teams running automation in remote testing environments, CI/CD pipelines, or centralized test labs, this behavior can lead to unreliable test execution and wasted debugging time.
The good news is that this issue has a simple and reliable solution. By applying a small Windows registry tweak on the machine that initiates the Remote Desktop connection, testers can keep the remote GUI active even when the RDP window is minimized.
In this guide, we’ll explain:
Why TestComplete Remote Desktop Testing fails when RDP is minimized
How Windows handles remote GUI rendering
The registry fix that prevents automation failures
Best practices for running TestComplete tests on remote machines
How to build a stable remote automation environment
By the end of this article, you’ll have a clear understanding of how to run reliable TestComplete automation in Remote Desktop environments without interruptions.
Why TestComplete Remote Desktop Testing Fails When RDP Is Minimized
When automation tests run on a remote machine through Remote Desktop, the graphical interface of the system is transmitted to the client computer.
However, Windows introduces a performance optimization.
When the Remote Desktop window is minimized:
Windows assumes the user is not viewing the remote screen
The operating system stops rendering the graphical interface
The session switches into a GUI-less mode
The application continues running, but the visual interface disappears.
According to the uploaded guide, this behavior occurs because Windows disables the graphical rendering of the remote desktop when the RDP window is minimized.
For everyday users, this optimization is harmless.
But for GUI automation tools like TestComplete, it creates serious problems.
Automation tools rely on visible UI components to:
Locate elements
Simulate user interactions
Validate interface behavior
Without the rendered interface, TestComplete cannot detect UI objects, causing automation failures.
Common Symptoms of the TestComplete RDP Minimized Issue
QA engineers typically encounter the following problems:
Tests fail only when Remote Desktop is minimized
UI objects cannot be identified
Automated clicks do not work
Scripts that worked earlier suddenly fail
Here’s a simple breakdown.
S. No
Symptom
Cause
1
TestComplete cannot find objects
Remote GUI not rendered
2
Automation clicks fail
Controls are invisible
3
Tests stop unexpectedly
UI elements unavailable
4
Tests pass locally but fail remotely
RDP session behavior
The Registry Fix for Reliable TestComplete Remote Desktop Testing
Fortunately, there is a reliable workaround.
By modifying a registry setting on the local machine used to connect via Remote Desktop, you can force Windows to keep the remote GUI active even when the RDP window is minimized.
The solution involves adding a DWORD value called RemoteDesktop_SuppressWhenMinimized.
Setting this value to 2 prevents Windows from suppressing the GUI rendering.
This ensures that automation tools like TestComplete continue interacting with UI elements even when the RDP session is minimized.
Step-by-Step Guide to Fix the TestComplete RDP Minimized Issue
Step 1: Open the Windows Registry Editor
Press Windows + R, then type:
regedit
Press Enter to open the Registry Editor.
Step 2: Navigate to the Terminal Server Client Key
Choose one of the following registry paths.
For Current User
HKEY_CURRENT_USER\Software\Microsoft\Terminal Server Client
For All Users
HKEY_LOCAL_MACHINE\Software\Microsoft\Terminal Server Client
Step 3: Create the Required DWORD Value
Create a new DWORD entry with the following configuration.
Name: RemoteDesktop_SuppressWhenMinimized
Value: 2
This tells Windows to keep the remote GUI active even when the RDP session is minimized.
Step 4: Apply the Fix for 64-bit Windows
If your machine uses 64-bit Windows, repeat the same step in:
HKEY_CURRENT_USER\Software\Wow6432Node\Microsoft\Terminal Server Client
or
HKEY_LOCAL_MACHINE\Software\Wow6432Node\Microsoft\Terminal Server Client
Add the same DWORD value.
RemoteDesktop_SuppressWhenMinimized = 2
Step 5: Restart the Remote Desktop Session
After updating the registry:
Close Registry Editor
Disconnect the Remote Desktop session
Reconnect to the remote machine
Your TestComplete Remote Desktop Testing environment should now run automation reliably.
Imagine a QA team running nightly regression tests using TestComplete.
Their environment includes:
Dedicated test machine
Remote Desktop access
Scheduled automation runs
During test execution, an engineer minimizes the Remote Desktop window.
Suddenly:
Automation fails
TestComplete cannot find UI elements
Regression tests stop halfway
After applying the registry fix described earlier, the team can minimize the RDP session without breaking the automation.
Now their automation environment:
Runs tests reliably overnight
Supports remote monitoring
Prevents random automation failures
Benefits of This TestComplete Remote Desktop Testing Fix
S. No
Benefit
Description
1
Stable automation runs
GUI remains visible to automation tools
2
Reliable overnight testing
RDP state no longer affects automation
3
Reduced debugging time
Prevents mysterious automation failures
4
Better CI/CD compatibility
Remote environments stay consistent
5
Improved QA productivity
Automation becomes predictable
Best Practices for Running TestComplete Tests on Remote Machines
Use Dedicated Automation Machines
Automation environments should run on machines that are not used for daily development tasks.
This avoids interruptions like:
Session logouts
Screen locks
Unexpected reboots
Avoid Locking the Remote Machine
Locking the screen can also affect GUI rendering.
Ensure the session remains active during automation runs.
Integrate Automation with CI/CD Pipelines
Many QA teams run automation through CI/CD systems such as:
Jenkins
GitHub Actions
Azure DevOps
These systems help automate test execution and reporting.
TestComplete Remote Desktop Testing vs Local Automation
S. No
Feature
Remote Desktop Testing
Local Testing
1
Scalability
High
Limited
2
Infrastructure
Centralized
Individual machines
3
Stability
Requires configuration
Generally stable
4
CI/CD compatibility
Excellent
Limited
5
Ideal for
Large QA teams
Individual testers
Final Thoughts
Running GUI automation in Remote Desktop environments can introduce unexpected issues if the system configuration is not optimized for automation tools. One of the most common problems QA teams encounter is the TestComplete RDP minimized issue, where tests fail because the remote graphical interface stops rendering. Fortunately, a simple registry tweak can prevent this behavior and ensure your automation environment remains stable. By keeping the remote GUI active, testers can run automation scripts reliably even when the Remote Desktop session is minimized.
Frequently Asked Questions
Why do TestComplete tests fail when the RDP session is minimized?
Windows disables the graphical rendering of the remote desktop when the RDP window is minimized. GUI automation tools cannot interact with UI elements that are not rendered.
Does this problem affect all GUI automation tools?
Yes. Any automation tool that relies on visible UI components may experience similar issues in Remote Desktop environments.
Where should the registry change be applied?
The registry tweak must be applied on the local machine initiating the Remote Desktop connection, not the remote machine.
Can TestComplete run automation on remote machines?
Yes. TestComplete supports remote execution using tools like TestExecute and integration with CI/CD systems.
Is the registry fix safe?
Yes. The change simply instructs Windows to keep rendering the remote desktop GUI even when minimized.
Although web and mobile applications are more widely used now, desktop applications still play an integral role for many organizations. So the need to automate desktop applications for testing purposes is still prevalent and we have many test automation tools in the market as well. Being an expert desktop application automation testing company, we have even developed our very own tool for Desktop App Automation called Gyra. Additionally, we also have strong expertise in the other tools from the market. So we wanted to list the best desktop application automation testing tools available as of 2024 and highlight their features so that you can choose the best tool suitable for your needs.
Types of Desktop Applications & Frameworks
But before heading straight to that, we must understand the different types of Desktop Applications and frameworks. So kindly find the list below
Win32 Apps – Applications that are created using WinAPI. These applications are typically native Windows GUI apps.
Windows Forms (WinForms) Apps – Applications that are created using frameworks like .NET, Delphi, or MFC instead of calling the Win32 API. WinForms was introduced more than 2 decades ago in the year 2001 with .NET 1.0 framework. As WinForms apps perform well in low-configured machines, it is still being used for its performance and lightweight UI.
WPF (Windows Presentation Foundation) Apps – It was released in the year 2006 to modernize Desktop App development as it enables you to create visually rich UI applications. WPF supports cross-platform application development using Avalonia UI. However, WinForms and WPF are still Windows-centric and there is no official statement from Microsoft yet.
Universal Windows Platform (UWP) Apps – UWP was introduced with Windows 10. You can run the Desktop apps developed using UWP on Windows Desktop PCs, Windows Mobile, Xbox, and mixed reality headsets.
Java AWT (Abstract Window Toolkit) – It is a heavy-weight platform-dependent API used to create Desktop Applications.
Java Swing – Swing is a legacy toolkit used to create Desktop Applications using Java.
JFX – JFX was introduced along with Java 8 and it can be used to create rich Java-based client applications. JFX supports FXML & CSS.
macOS Apps – Used to create Desktop Applications for macOS using Xcode & Swift programming
Electron – Electron is a framework that can be used to develop desktop applications using JavaScript, HTML, & CSS.
QT – QT is a C++ framework. You can build cross-platform desktop applications with native user interfaces.
Best Desktop Application Automation Testing Tools
Now that we have seen what types of desktop applications and frameworks are out there, let’s take a look at the highlights of all the tools one after another to help you choose the best desktop application automation testing tool in 2024. We’re starting the list with FlaUI.
FLAUI
FlaUI is a .NET library.
Supported Apps: You can automate Win32, WinForms, WPF, & UWP applications.
Programming Language: C#
It uses Microsoft’s UI Automation framework to access the UI elements programmatically.
It supports XPath locators for some properties.
It has automation support for the QT framework type.
It requires a steep learning curve.
It does not support Swing & JFX applications.
You can’t perform remote execution like how you do it using Selenium RemoteWebDriver
Latest version: v4.0.0
WinAppDriver (Windows Application Driver)
It is a popular freeware library used for Desktop Application Automation Testing.
Supported Platforms – Windows 10 and Windows Server 2016.
Supported Application Types – UWP, WPF, WinForms, and legacy Win32.
Prerequisite – You need to enable Developer Mode in Windows Settings before performing execution.
You can run scripts on a remote machine.
It has its own UI recorder which can generate scripts in C#.
You can also attach the already launched application and perform action on it.
You can create test scripts in two ways – Keyword Tests and Script Tests.
Keyword Tests helps you to create Test Scripts in Table format instead of writing coding. When you record the user actions, Test Complete populates Test Scripts in the Keyword Tests table.
Keyword Test is helpful if you are doing POC. But if you are looking to create a robust test suite, go for Script Tests.
Another notable feature of Test Complete is you can create BDD tests. If you have your Gherkin feature files in Cucumber Studio, you can easily import them into Test Complete.
Latest version 15.65
Gyra
Gyra is Codoid’s Home-grown Desktop Application Automation Testing Tool that is available as a freeware.
Supported Programming Language – Java.
It is easy to set up as it requires no additional configurations.
Execution is fast compared with other tools.
Ranorex
Supported Apps – WinForms, WPF, Qt, Java, Delphi, SAP, UWP, MSAA/UIA, CEF, .NET Core, Office and many more.
As an automation testing service provider, we understand that desktop app automation is more challenging when compared to web and mobile app automation. Given the additional complexity, choosing the right tool for your automation needs is very important. If you choose the right tool and are able to see success in a Proof of Concept, then you are halfway through. We hope the overview we provided for each desktop application automation testing tool will help you in your decision-making process.
Despite the rise of people using mobile applications, desktop applications are still being used on a daily basis by many. Though you can test a desktop application manually, it is still important for a tester to know how to automate desktop applications in Windows. There are a few ways to go about it, and in this blog, we will be focusing on how to automate a desktop application using C#. In order to achieve that, we’ll be sharing the tried and tested frameworks, tools, strategies, and approaches we have been using over the years to deliver exceptional automated desktop application testing services to our clients. We’ve also provided an example to help you understand everything clearly. So let’s get started.
.NET Framework
.NET Framework is a software development platform developed by Microsoft to build and run windows applications. .NET is used to automate applications in different operating systems such as Linux, macOS, and Windows. Whereas, .NET framework was developed specifically for Windows. So it can be used to run applications in windows environments that were created using the .NET framework.
WinAppDriver (Windows Application Driver)
WinAppDriver is also a test automation framework developed by Microsoft. It is an open-source option that feels like a combination of a WebDriver and Appium. We say this as WinAppDriver is a set of libraries that can be integrated into a test runner that supports Appium. For those who don’t know, Web drivers are used for desktop application automation and Appium is used for mobile app automation. Before we proceed to see how to automate a Desktop application using C#, let’s take a look at the prerequisites for WinAppDriver
Windows 10 OS
Visual Studio 2013+
WinAppDriver.exe
Turn ON Developer mode on the PC
BDD Approach
We have used the BDD approach in numerous automation testing projects and have always been satisfied with the results. That is why we have decided to focus on it while explaining how to automate a desktop application using C#. BDD is expanded as Behavior Driven Development, it is an Agile software development process that allows the design, creation, and product testing, using the product’s behavior.
But the major advantage is that it makes it very easy for even non-technical users to understand the purpose of every test without having to know technical terms like classes, methods, and variables. All the important aspects will be explained using Gherkin language that is in the Given, When, and Then format.
Since we will be automating Notepad in our example, we’ve created a feature file in the Gherkin language for easier understanding.
@Demo
Scenario: Notepad Demo
Given Launch Notepad
When Enter Specified Text
Then Verify the Entered Text
Specflow
Now that we have discussed the approach we’ll be using, let’s focus on the Specflow, the solution that can be used to implement BDD in our framework. We can use the Gherkin language as mentioned above and bind the steps definitions for desktop applications. If you haven’t yet installed Specflow, you can easily do so by using the NuGet manager in any Visual Studio project.
@Demo
Scenario: Notepad Demo
Given Launch Notepad
When Enter Specified Text
Then Verify the Entered Text
Inspectors
When it comes to web automation, we can find different locators by inspecting the webpage. But that will not be possible when it comes to desktop app automation. That is why knowing how to use a UI Inspector is a crucial part of learning how to automate a desktop application using C#.
Using either one of these UI inspectors, you’ll be able to see the DOM of the desktop application and get the locators of elements such as ID, Name, ClassName, XPath, and so on.
How to Automate a Desktop Application using C#?
First up, we’ll need to create a new project in Visual Studio using the Console App (.NET Framework)
Install Specflow
We have to then install and set Specflow up by
Navigating to Project > Manage NuGet Packages
Search for Specflow and click on Specflow to install it
We have to then add Specflow.NUnit and Specflow.Tools.MsBuild.Generation from the same NuGet packages
Installing WinAppDriver
We need to install WinAppDriver from GitHub to launch and access the desktop application we wish to automate. WinAppDriver will create a bridge for the application and our tests. You’ll have to enable the developer mode in Windows to run WinAppDriver.
To access the WinAppDriver classes and methods, we need to add Appium.Webdriver to our project from NuGet packages
The next step would be to Create a Feature file. You can do so by right-clicking on the Feature folder > Add > New item > Search for Feature File for Specflow as shown in the below image.
Framework Setup
Now that everything is installed and ready, we’ll be seeing how to set up the framework in our How to automate a desktop application using C# blog. You’ll have to,
Taking screenshots during test execution and generating reports is an integral part of knowing how to automate a desktop application using C#. And you’ll need the windowsUtils class file to achieve that.
public class windowsUtils
{
static WindowsDriver<WindowsElement> window;
static windowsUtils()
{
window = LaunchApp("C:\\ProgramData\\Microsoft\\Windows\\Start Menu\\Programs\\Accessories\\Notepad.lnk");
}
public static WindowsDriver<WindowsElement> getWindowInstance()
{
return window;
}
public static WindowsDriver<WindowsElement> LaunchApp(String _ApplicationLocation)
{
try
{
AppiumOptions options = new AppiumOptions();
options.AddAdditionalCapability("app", _ApplicationLocation);
options.AddAdditionalCapability("deviceName", "WindowsPc");
window = new WindowsDriver<WindowsElement>(new Uri("http://127.0.0.1:4723/"), options);
}
catch (Exception ex)
return window;
}
Create a class file for the Base window
We’ll next have to use WinAppDriver to perform Desktop App Automation testing. So we have mentioned the code you’ll need to use to create the class file for the Base window.
public class baseWindow
{
public WindowsDriver<WindowsElement> window;
public baseWindow(WindowsDriver<WindowsElement> window)
{
this.window = window;
}
public WindowsDriver<WindowsElement> getWindowInstance(String _ApplicationLocation)
{
try
{
AppiumOptions options = new AppiumOptions();
options.AddAdditionalCapability("app", "C:\\ProgramData\\Microsoft\\Windows\\Start Menu\\Programs\\Accessories\\Notepad.lnk");
options.AddAdditionalCapability("deviceName", "WindowsPc");
window = new WindowsDriver<WindowsElement>(new Uri("http://127.0.0.1:4723/"), options);
}
catch (Exception ex)
return window;
}
Create a class file for the Methods
We then create a class for the methods to perform the required action in the desktop application. In our case, we have chosen Notepad. And we will be entering the word “Codoid Innovations” and validating if the specified text has been displayed.
public class Notepad : baseWindow
{
static WindowsDriver<WindowsElement> _window;
public Notepad(WindowsDriver<WindowsElement> window) : base(window)
{
_window = this.window;
}
public By Text => By.Name("Text Editor");
public By Verifyinput => By.Name("Text Editor");
public void Maximize()
{
window.Manage().Window.Maximize();
}
public void enterText()
{
window.FindElement(Text).SendKeys("Codoid Innovations");
}
public bool VerifytheText()
{
bool result = window.FindElement(Verifyinput).Displayed;
return result;
}
}
Run the Test
Finally, we can run the test by opening the command prompt from the file location and using the following command
“nunit3-console.exe filename –where “cat==tagname from the feature file””
Note: Based on your requirements, you can either add Extent report or Allure report from the nuget packages.
Conclusion
We hope you now have a clear picture of how to automate a desktop application using C# after reading our blog. As a pioneer automation testing company, we have even developed our very own desktop app automation tool called Gyra. If you are unfamiliar with C#, give Gyra a try as it is a free tool that works with Java. We will be publishing more informative content on our website, and we recommend you subscribe to our newsletter to not miss out on any of those content.