Getting Started with FlaUI: Open-Source UI Automation for Windows Apps

Table of Contents

Getting Started with FlaUI: Open-Source UI Automation for Windows Apps

Introduction

An open-source.NET package called FlaUI (short for “Framework for Automated UI Testing”) is used to automate and test Windows applications. It is based on Microsoft’s UI Automation frameworks, including Microsoft Active Accessibility (MSAA) and UI Automation (UIA3).

Automated UI tests are necessary for software development. Nowadays, software applications are large and packed with numerous features. Testing all these features manually on a regular basis is time-consuming and often impractical. To address this challenge, automated UI tests are used. These tests are designed to run without any manual intervention. You can initiate the tests overnight and review the results of hundreds of test cases the next morning.

FlaUI is a well-known and reliable open-source framework for creating automated UI tests specifically for Windows desktop applications. FlaUI provides simple Application Programming Interface (API) to perform daily tasks faster by test script developers. Finding UI elements is the most challenging task in UI test creation. FlaUInspect is a tested tool to identify UI elements. FlaUI also provides smooth integration with test frameworks like xUnit, NUnit, and MSTest.

Features of FlaUI

1. Many APIs for UI Automation

  • Supports UIA2 (Microsoft UI Automation 2.0) and UIA3 (Microsoft UI Automation 3.0) for UI automation
  • It is recommended to use UIA3 as it is more advanced and compatible with modern applications


2. Supports Multiple Application Types

  • It can automate Universal Windows Platform (UWP) applications, Windows Presentation Foundation (WPF), WinForms, and Win32
  • Enables third-party frameworks like Telerik, DevExpress, and Infragistics to work efficiently


3. Facilitates UI Elements Interactions Directly

  • Fully supports clicking, typing, selecting, and interacting with UI elements
  • For deeper interaction, it uses patterns like Invoke, Value, Selection, Grid, Table, Scroll, and Toggle


4. Logging and Screenshot Support

  • Captures screenshots for debugging and reporting
  • Provides detailed logs to track errors and UI interactions


5. Searching for Windows and Elements

  • Uses XPath, AutomationId, Name, ClassName, and ControlType to find elements
  • Supports fluent APIs to search for UI elements


6. Automation for Keyboard and Mouse

  • Automates keyboard inputs (key presses, text entry). It can simulate scrolls, clicks, drags, and mouse movements


7. Can Integrate Testing Frameworks

  • It can work with NUnit, xUnit, and MSTest for UI testing
  • It can also work with SpecFlow for Behavior-Driven Development (BDD)


8. No External Dependencies

  • It does not require any external driver
  • Native Windows automation APIs are used for fast and stable automation


9. Supports Cross-Applications and Cross-Processes

  • Applications running in different processes can be automated
  • It can work across multiple application windows simultaneously


10. It is Open-Source and Actively Maintained

  • It is available on NuGet and GitHub
  • It is actively maintained by the community with regular updates. Version 5.0 has been released recently

FlaUI vs Tosca for Automated UI Tests

Tosca is a popular commercial tool for automated UI testing. FlaUI and Tosca use different approaches for automating UI tests. One of the major differences is cost. FlaUI is free and Tosca is very expensive. That’s why FlaUI is recommended. Detailed differences are as below.

  FlaUI  Tosca 
Language and Scripting  It requires coding in C#. It’s a library, not a UI tool, so we need to write automation scripts in C# code.  It uses a script-less approach with a model-based framework. Testers can create test cases using a drag-and-drop UI interface. 
Learning Curve  It requires a steep learning curve for beginners. We need to know concepts of C# and UI automation.  It is easier to use for non-developers because it does not require coding knowledge. 
Supported Applications  The primary target is Windows UI automation (WPF, WinForms, Win32, and UI Automation framework). Very limited web support is available.  It supports Web, Desktop, Mobile, API, and Database automation. 
Cost  Free and open source at no cost.  It is a paid enterprise tool and is expensive for small teams. 
CI/CD & Integration  It can work well with Selenium, Appium, NUnit, MSTest, and other .NET frameworks and can integrate with Azure DevOps.  It provides out-of-the-box integrations with Jira, Jenkins, Azure DevOps, SAP, and ServiceNow. 
Use Cases  It is best for developers who need a customizable and lightweight solution for Windows application automation.  It is Ideal for large enterprises that need end-to-end test automation across multiple platforms without coding. 

Libraries of FlaUI

FlaUI is modular and consists of several libraries, each serves a different purpose:

1. FlaUI.Core

  • The main library provides shared functionality for UI automation
  • It contains essential classes like Application, AutomationElement, and ConditionFactory


2. FlaUI.UIA2 

  • It implements UI Automation 2 (UIA2) using MSAA
  • Suitable for older Windows applications


3. FlaUI.UIA3

  • Implements UI Automation 3 (UIA3), based on Microsoft’s latest UIA framework
  • Suitable for modern Windows applications (Windows 10 and later)


4. FlaUI.Core.Conditions

  • It facilitates condition-based filtering for UI elements (like, by name, by type, or by automation ID)


5. FlaUI.Core.Input

  • Methods are available for simulating keyboard and mouse interactions


6. FlaUI.Core.Logging

  • It is for logging automation activities while writing UI tests

Inspecting UI Controls Using Inspector

FlaUInspect is a UI inspection tool designed for identifying and analyzing UI elements in Windows applications. It is an alternative to Microsoft’s Inspect.exe and is specifically built for use with FlaUI (Framework for UI Automation).

It helps testers and developers inspect automation properties of UI elements that are essential for writing automated UI tests.

1. Both UIA2 and UIA3 are supported

  • It works with both UI Automation 2 (UIA2) and UI Automation 3 (UIA3) frameworks
  • UIA2 is for legacy applications, while UIA3 has been devised for modern Windows apps


2. Finds Automation Properties

  • Provides details like:
    • AutomationId (unique identifier of an element)
    • Name (text displayed for the element)
    • ControlType (e.g., Button, TextBox, ComboBox)
    • BoundingRectangle (position and size of the element)
    • FrameworkId (technology used, e.g., WinForms, WPF)


3. Live UI Inspection

  • Allows users to hover over UI elements and instantly view their properties
  • Helps in identifying elements for automated testing


4. Tree View Representation

  • Displays the entire UI hierarchy in a tree structure, making it easy to navigate through elements


5. Highlight UI Elements

  • Selects and visually highlights UI components in the application window


6. Search and Filtering are supported

  • It can quickly locate UI elements based on their properties


7. It is Free and Open Source

  • It is available on GitHub and can be customized if needed

Writing Test Case Using FlaUI

FlaUI is a .NET library for UI automation that helps in writing test cases for Windows applications. It supports automation via UIA2 (older UI Automation framework) and UIA3 (newer UI Automation framework). Here’s how we can write a basic test case using FlaUI.

Sample Test Case with NUnit and C#: Automating Notepad

Sample Test Case with NUnit and C#

Explanation:

1. SetUp Method:

  • Launches Notepad before the test
  • Initializes UIA3Automation


2. Test Case:

  • Test_Notepad_TitleCheck: Verifies if the Notepad app is opened with the correct title


3. TearDown Method:

  • Closes the application after each test to ensure clean execution

Creating Custom Testing Framework Based on FlaUI

We can create a framework in .NET based on FlaUI library. This framework can hide the complexity of using FlaUI for test script developers.

Features of custom framework that can be accommodated:

  • A class that supports performing operations on UI like button click, dropdown selection, and writing on textbox
  • Test report creation (using extent report NuGet package)
  • Supports the creation of automated UI tests running on multiple devices simultaneously using socket programming
  • Updating status of test steps for Azure DevOps (ADO)
  • While FlaUI does not provide direct support for Java desktop applications, automated UI tests can still be created using the Java Access Bridge library provided by Oracle, which enables interaction with Java-based UI components
  • Image-based UI Control Locator to perform operations on UI controls for which automation Id is unknown
  • User to log information and errors
  • Utility methods are provided to assist test script developers with operations such as Excel, CSV, file handling, date manipulation, screenshots, PDF processing, and more
  • We need some base classes in the framework that can be inherited by classes of the test project. These framework classes have special test methods like Setup, OnetimeSetup, TearDown, and OneTimeTearDown of NUnit or some other test framework. These base classes can initialize features like reports, uploading logs into ADO, and others. The base classes of the framework are as follows:
    • CoreEnvSetup: We can rename it as suitable. This class has OneTimeSetUp and OneTimeTearDown methods of NUnit or some other similar test framework. We can initialize reports and other required classes in OneTimeSetUp method. OneTimeTearDown is used for cleanup of our custom framework functionality and other requirements. The class in the test project that inherits these, also implements OneTimeSetUp and OneTimeTearDown methods as a test project requirement.ProductEnvSetup (Class in test project) -> CoreEnvSetup (class of custom framework)
    • CoreTest: We can rename it as suitable. This class works as a base class for test classes of the test project. We can also create a base class at Test project level that inherits the CoreTest and every Test class can further inherit the base class of the test project. The CoreTest class has SetUp and TearDown method of NUnit or some other similar test framework. We can initialize required classes here in SetUp method for test class level of custom framework. TearDown is used for cleanup of Test class and other related requirements at custom framework level. The base class of the test project that inherits CoreTest, can also implement SetUp and TearDown methods as a test requirement.Test class in test project à ProductBaseTest (base class in test project) -> CoreTest (class of custom framework)

Note: The test project adds reference to the Dynamic-Link Library (DLL) of the above custom framework and starts using the features of a custom framework.

Conclusion

We can use FlaUI when we create automated UI tests for Windows desktop applications, and costing is a major concern for us.

Know More: UI/UX Testing Services

References

https://github.com/FlaUI/FlaUI
https://learn.microsoft.com/en-us/dotnet/framework/UI-automation/UI-automation-overview
https://www.oracle.com/java/technologies/javase/javase-tech-access-bridge.html
https://github.com/google/access-bridge-explorer/tree/master/src/WindowsAccessBridgeInterop

Authors

Vaishali Pandya                                   
Vaishali Pandya                                 Rahul Gupta

Explore More

Talk to an Expert

Subscribe
to our Newsletter
Stay in the loop! Sign up for our newsletter & stay updated with the latest trends in technology and innovation.

Download Report

Download Sample Report

Download Brochure

Start a conversation today

Schedule a 30-minute consultation with our Automotive Solution Experts

Start a conversation today

Schedule a 30-minute consultation with our Battery Management Solutions Expert

Start a conversation today

Schedule a 30-minute consultation with our Industrial & Energy Solutions Experts

Start a conversation today

Schedule a 30-minute consultation with our Automotive Industry Experts

Start a conversation today

Schedule a 30-minute consultation with our experts

Please Fill Below Details and Get Sample Report

Reference Designs

Our Work

Innovate

Transform.

Scale

Partnerships

Device Partnerships
Digital Partnerships
Quality Partnerships
Silicon Partnerships

Company

Products & IPs

Privacy Policy

Our website places cookies on your device to improve your experience and to improve our site. Read more about the cookies we use and how to disable them. Cookies and tracking technologies may be used for marketing purposes.

By clicking “Accept”, you are consenting to placement of cookies on your device and to our use of tracking technologies. Click “Read More” below for more information and instructions on how to disable cookies and tracking technologies. While acceptance of cookies and tracking technologies is voluntary, disabling them may result in the website not working properly, and certain advertisements may be less relevant to you.
We respect your privacy. Read our privacy policy.

Strictly Necessary Cookies

Strictly Necessary Cookie should be enabled at all times so that we can save your preferences for cookie settings.