Search Results for

    Show / Hide Table of Contents

    Windows

    This quick start will get you up and running with writing UI tests for a Windows (UWP) application using the WinAppDriver and Legerity.

    Prerequisites

    This quick start requires the following:

    • An understanding of Selenium and working with the WebDriver APIs in .NET
    • A functioning installation of the .NET runtime and SDK
    • A Windows 10 or Windows 11 device with the WinAppDriver installed

    Install Legerity templates

    Legerity includes project templates to simplify the creation of new UI test projects. To install the templates, run the following command:

    dotnet new -i Legerity.Templates
    

    When creating a project, the template will automatically add to an existing solution file if it can locate one, otherwise you will have to add it manually.

    Create a new Windows UI test project with NUnit

    To create a new Windows UI test project with NUnit in your existing repository, created a new project folder and from within it, run the following command:

    dotnet new legerity-windows
    

    This will create a new Windows UI test project with the following structure:

    MyProject
    ├── Elements
    ├── Pages
    │   └── SamplePage.cs
    ├── Tests
    │   └── SampleTests.cs
    ├── BaseTestClass.cs
    ├── GlobalUsing.cs
    ├── MyProject.csproj
    

    The project will include dependencies for NUnit, Appium, and Legerity for Windows (including WinUI).

    The BaseTestClass class is a simple abstraction used for all of your test classes, based on the Legerity LegerityTestClass. The base test class is a great way to centralize common logic for your tests, to abstract the boilerplate code away from your tests, such as managing the application drivers.

    Note

    The BaseTestClass in this template is currently configured to launch the Clock application on Windows 11. This should be updated to launch your own application via the WindowsApplication constant.

    The SamplePage and SampleTests classes are used to show the basic structure of a page object and test class. In this template, they highlight the launch and verification of the landing page of the Clock application on Windows 11.

    Note

    The SamplePage and SampleTests classes are intended to be used as a guide for structuring tests. These should be removed and replaced with your own tests and page objects.

    Run the tests

    To run the tests, you can use the following command from the UI test project:

    dotnet test
    

    The Clock application should launch and the tests should pass.

    Dive into more

    Now that you have your test project up and running, you can dive deeper into:

    • Using the base test class
    • Creating page objects
    • Creating test classes
    • Locating elements with Legerity by locators
    • Using and creating element wrappers
    • Using custom conditions to wait for elements
    • Improve this Doc
    In This Article
    Back to top Copyright (c) MADE Apps