Skip to content
UI automation library for .Net
Branch: master
Clone or download
marcelo-maciel and Roemer Update README.md (#202)
On a new Winfors project, if I simple reference Application, VS understand that is System.Windows.Forms.Application and if i add "using FlaUI.Core", VS show "ambiguous reference" error, then I sugest to use the full name.
Latest commit b29b830 Aug 25, 2018
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.cake Moved cake to .cake and updated it Jul 3, 2018
src Implemented a mouse drag from point to point (shamelessly copied from @… Aug 10, 2018
.gitignore Moved cake to .cake and updated it Jul 3, 2018
CHANGELOG.md Update CHANGELOG.md Oct 20, 2017
FlaUI.png
FlaUI.snk
LICENSE.txt Updated version to 2.0.0-rc1 Jul 10, 2018
README.md Update README.md (#202) Aug 25, 2018
VERIFICATION.txt Added files for automated artefact creation Dec 20, 2016
build.cake Added Push-To-Nuget cake task Jul 10, 2018
build.ps1 Moved cake to .cake and updated it Jul 3, 2018
cake.config Moved cake to .cake and updated it Jul 3, 2018

README.md

Alt text

Badges

What Badge
Chat Join the chat at https://gitter.im/FlaUI/Lobby
Build Build status
Tests Test status
Libraries (NuGet) NuGet FlaUI.Core NuGet FlaUI.UIA2 NuGet FlaUI.UIA3
CI Artefacts FlaUI CI

Introduction

FlaUI is a .NET library which helps with automated UI testing of Windows applications (Win32, WinForms, WPF, Store Apps, ...).
It is based on native UI Automation libraries from Microsoft and therefore kind of a wrapper around them.
FlaUI wraps almost everything from the UI Automation libraries but also provides the native objects in case someone has a special need which is not covered (yet) by FlaUI.
Some ideas are copied from the UIAComWrapper project or TestStack.White but rewritten from scratch to have a clean codebase.

Why another library?

There are quite some automation solutions out there. Commercial ones like TestComplete, Ranorex, CodedUI just to name a few. And also free ones which are mainly TestStack.White.
All of them are based on what Microsoft provides. These are the UI Automation libraries. There are three versions of it:

  • MSAA
    • MSAA is very obsolete and we'll skip this here (some like CodedUI still use it)
  • UIA2: Managed Library for UI Automation
    • UIA2 is managed only, which would be good for C# but it is not maintained anymore and does not support newer features (like touch) and it also does not work well with WPF or even worse with Windows Store Apps.
  • UIA3: Com Library for UI Automation
    • UIA3 is the newest of them all which is still the actual version (and should be maintained). This one works great for WPF / Windows Store Apps but unfortunately, it can have some bugs with WinForm applications (see FAQ) which are not existent in UIA2.

So, the commercial solutions are mostly based on multiple of those and/or implement a lot of workaround code to fix those issues. TestStack.White has two versions, one for UIA2 and one for UIA3 but because of the old codebase, it's fairly hard to bring UIA3 to work. For this, it also uses an additional library, the UIAComWrapper which uses the same naming as the managed UIA2 and wraps the UIA3 com interop with them (one more source for errors). FlaUI now tries to provide an interface for UIA2 and UIA3 where the developer can choose, which version he wants to use. It should also provide a very clean and modern codebase so that collaboration and further development is as easy as possible.

Usage

Installation

To use FlaUI, you need to reference the appropriate assemblies. So you should decide, if you want to use UIA2 or UIA3 and install the appropriate library from NuGet. You can of course always download the source and compile it yourself.

Usage in Code

The entry point is usually an application or the desktop so you get an automation element (like a the main window of the application). On this, you can then search sub-elements and interact with them. There is a helper class to launch, attach or close applications. Since the application is not related to any UIA library, you need to create the automation you want and use it to get your first element, which then is your entry point.

using FlaUI.UIA3;

var app =  FlaUI.Core.Application.Launch("notepad.exe");
using (var automation = new UIA3Automation())
{
	var window = app.GetMainWindow(automation);
	Console.WriteLine(window.Title);
	...
}
using FlaUI.UIA3;

var app = FlaUI.Core.Application.Launch("calc.exe");
using (var automation = new UIA3Automation())
{
	var window = app.GetMainWindow(automation);
	var button1 = window.FindFirstDescendant(cf => cf.ByText("1"))?.AsButton();
	button1?.Invoke();
	...
}

Contribution

Feel free to fork FlaUI and send pull requests of your modifications.
You can also create issues if you find problems or have ideas on how to further improve FlaUI.

Acknowledgements

resharper Thanks to JetBrains for providing a free license of ReSharper.

You can’t perform that action at this time.