Unicorn.UI.Win 4.0.0

dotnet add package Unicorn.UI.Win --version 4.0.0                
NuGet\Install-Package Unicorn.UI.Win -Version 4.0.0                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Unicorn.UI.Win" Version="4.0.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Unicorn.UI.Win --version 4.0.0                
#r "nuget: Unicorn.UI.Win, 4.0.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Unicorn.UI.Win as a Cake Addin
#addin nuget:?package=Unicorn.UI.Win&version=4.0.0

// Install Unicorn.UI.Win as a Cake Tool
#tool nuget:?package=Unicorn.UI.Win&version=4.0.0                

Nuget Nuget

Unicorn.UI.Win

Implementation of desktop GUI interaction based on UIA3 library.

  • GUI Driver implementation
  • Typified controls implementations
  • PageObject implementation
  • UI actions
  • User input clients (mouse, keyboard)

PageObject example

public class TestAppWindow : Window
{
    public TestAppWindow()
    {
    }

    public TestAppWindow(IUIAutomationElement instance)
        : base(instance)
    {
    }

    // Control of any type derived from WebControl could be a part of page object.
    // Controls implementing predefined controls interfaces allow to apply type specific matchers 
    // to make tests and assertions easier and more readable.
    [Name("'Switch app' button"), ById("switchAppButton")]
    public Button SwitchAppToggle { get; set; }

    // Controls could be located using generic FindAttribute.
    [Name("'Hello World' view"), [Find(Using.Id, "HelloWorldView")]
    public HelloWorldView HelloWorldView { get; set; }

    // Name attribute allows control to be self-reportable in combination with matchers 
    // and to be logged with scpecified name
    [Name("'Hello World' view"), ById("SampleView")]
    public SamplesView SamplesView { get; set; }

    [Name("Modal window"), ByClass("#32770")]
    public ModalWindow Modal {  get; set; }
}

Creating custom application

// Describes desktop application (TestWindowsApp application).
// should inherit Application.
public class TestWindowsApp : Application
{
    // Application constructor. Calls base constructor with path to application and application executable name.
    public TestWindowsApp() : base("", "path_to_application")
    { 
    }

    // main application window
    public TestAppWindow Window { get; private set; }

    public override void Start()
    {
        // Application.Start starts app by path provided in constructor and stores Process info
        base.Start();

        IUIAutomationElement element = null;

        // Initializing built-in waiter
        DefaultWait wait = new DefaultWait(TimeSpan.FromSeconds(5), TimeSpan.FromMilliseconds(250));
        wait.IgnoreExceptionTypes(typeof(COMException));

        // And wait until window with process window handle is found
        wait.Until(() =>
        {
            element = WinDriver.Instance.Driver.ElementFromHandle(Process.MainWindowHandle);
            return true;
        });

        Window = new TestAppWindow(element);
    }
}

Built-in matchers

Assert.That(application.Window, UI.Window.HasTitle("'Hello World' app"));
Assert.That(application.TitleDropdown, UI.Dropdown.HasSelectedValue(""));
Assert.That(application.NameInput, UI.TextInput.HasValue(string.Empty));
Product Compatible and additional computed target framework versions.
.NET net6.0-windows6.0 is compatible.  net7.0-windows was computed.  net8.0-windows was computed. 
.NET Framework net462 is compatible.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
4.0.0 92 12/7/2024
3.1.0 128 5/25/2024
3.0.0 788 4/9/2022
2.3.0 615 2/27/2021
2.2.1 551 10/2/2020
2.2.0 603 6/12/2020