TestUtilities - FlaUI/FlaUI GitHub Wiki

FlaUI.TestUtilities

Various utilities that can help writing FlaUI tests.

They can be found as a separate NuGet package: FlaUI.TestUtilities

Overview and usage

The following helper methods are included in this package

FlaUITestBase

This class allows to easily write test fixtures with FlaUI. It includes taking screenshot or videos of your tests and starts / stops / restarts the application that should be tested.

Usage

A basic example would look like this:

[TestFixture]
public class MyTestFixture : FlaUITestBase
{
    protected override AutomationBase GetAutomation()
    {
        return new UIA3Automation();
    }

    protected override Application StartApplication()
    {
        var app = Application.Launch("myexecutable.exe");
        app.WaitWhileMainHandleIsMissing();
        return app;
    }

    [Test]
    public void MyTestMethod()
    {
        var mainWindow = Application.GetMainWindow(Automation);
        Assert.That(mainWindow, Is.Not.Null);
    }
}

The minimum methods that needs to be implemented are the GetAutomation and the StartApplication method.

There are also several other methods and properties that can be adjusted.

Name Type Description
ApplicationStartMode Property Specifies the starting mode of the application to test.
VideoRecordingMode Property Specifies the mode of the video recorder.
KeepVideoForSuccessfulTests Property Flag to indicate if videos should be kept even if the test did not fail.
TestsMediaPath Property Path of the directory for the screenshots and videos for the tests.
AdjustRecorderSettings Method Method which allows customizing the settings for the video recorder.
CaptureImage Method Method which captures the image for the video and screen shots.

NUnitProgressLogger

This is a FlaUI logger which logs to the NUnit progress stream so that the messages are immediately visible in the NUnit console output.

Usage

The usage is fairly simple, just set the default logger to an instance of this logger:

Logger.Default = new NUnitProgressLogger();