Skip to content

Slint UI Testing with Python

Use the Slint UI Testing module to launch a Slint application locally or on a remote machine through SSH, inspect its UI, trigger actions, and verify correct behavior.

This documentation describes slint_testing 0.6.1.

Build your application with system testing support:

  • For Rust applications, enable the system-testing feature of the slint crate.
  • For C++ applications, set SLINT_FEATURE_SYSTEM_TESTING=ON in your CMake configuration.

In addition, set the SLINT_EMIT_DEBUG_INFO=1 environment variable when you build your application. We plan to replace this requirement with an easier mechanism in the future.

slint_testing is distributed through Slint’s package index at testing.slint.dev. With your license you receive an access token.

  1. Give the token to uv, once per machine:

    Terminal window
    uv auth login https://testing.slint.dev/simple/ --token <TOKEN>

    uv remembers it for testing.slint.dev, so it never appears in your project.

  2. Point your project at Slint’s index for slint-testing only, in pyproject.toml:

    [[tool.uv.index]]
    name = "slint-private"
    url = "https://testing.slint.dev/simple/"
    explicit = true
    [tool.uv.sources]
    slint-testing = { index = "slint-private" }

    explicit = true keeps PyPI as the default for everything else. The URL holds no token, so commit this even if your repository is public.

  3. Add the package:

    Terminal window
    uv add slint-testing

Store the token as a repository secret. uv reads the credentials for an index from environment variables named after it (slint-private → SLINT_PRIVATE), so you don’t need to run uv auth login. For GitHub Actions, use the following:

- uses: astral-sh/setup-uv@v6
with:
enable-cache: true
- run: uv sync
env:
UV_INDEX_SLINT_PRIVATE_USERNAME: __token__
UV_INDEX_SLINT_PRIVATE_PASSWORD: ${{ secrets.SLINT_TESTING_TOKEN }}

For a complete workflow that runs tests on Linux, macOS, and Windows, see the CI workflow ↗ of the examples.

The token also works in the index URL, https://testing.slint.dev/t/<TOKEN>/, without uv auth login. uv then writes that URL, token included, into uv.lock, so keep it out of public repositories.

The following example converts a temperature and checks the result:

import slint_testing
with slint_testing.Application(["/path/to/my_app"]) as aut:
window = aut.first_window
root_element = window.root_element
celsius_field = root_element.query_descendants().match_id("App::celsius-input").find_first()
convert_button = root_element.query_descendants().match_id("App::convert-button").find_first()
fahrenheit_field = root_element.query_descendants().match_id("App::fahrenheit-input").find_first()
celsius_field.accessible_value = "100"
convert_button.invoke_accessible_default_action()
assert fahrenheit_field.accessible_value == "212"

The slint_testing module provides an Application class, which wraps the Application Under Test (AUT). Construct it with the command line arguments needed to launch the compiled application, and use it with Python’s with ↗ statement. Before your block runs, slint_testing launches the application and waits until its first window is shown and connected.

To find UI elements, follow these steps:

  1. Fetch the Window from the Application, and then its root_element.
  2. Use query_descendants to start a query into the tree of elements.
  3. Refine the query, for example, with match_id.
  4. Obtain Element references to the UI elements by calling find_first or find_all.

Use Element‘s API to change state through accessible actions, and to verify size, position, and accessible properties.

The ui-testing-examples ↗ repository contains example applications written in Rust, C++, Node.js, and Python, each with a suite of tests. They show how to build an application with system testing support, launch it from pytest fixtures, and find and interact with elements. Each example is self-contained, so you can copy its directory as a starting point for your own project.

The slint_testing module and the AUT exchange messages over a TCP connection. slint_testing creates a listening TCP socket and passes its address to the AUT in the SLINT_TEST_SERVER environment variable. When the AUT is built with system testing support, it automatically attempts to connect to that socket when its first window is shown. Like an end user, slint_testing treats the visible window as a sign that the application is ready.

When launched through SSH, slint_testing configures SSH to open a listening socket on the remote side at port 8091 and configures a remote tunnel to forward to the local socket slint_testing created.


© 2026 SixtyFPS GmbH