Skip to content
pyguitest 0.30.0

pyguitest 0.30.0

Pypi • November 27, 2026

Desktop GUI automation and UI testing for Linux, BSD, Windows and macOS; successor to X11::GUITest

pip install pyguitest==0.30.0

Python GUI automation for real desktop applications.

Automate and test Linux, BSD, Windows and macOS desktop applications from Python — even when the application has no automation API.

Pyguitest provides one Python API for mouse, keyboard, window, screenshot, and accessible UI automation across Wayland, X11, XWayland, Windows and macOS.

🧪 Build reliable desktop GUI tests

🤖 Automate repetitive desktop tasks

🖱️ Control applications like a real user

🔎 Find and interact with accessible UI elements

📸 Capture screenshots and failure artifacts

🧰 Diagnose desktop automation environments

🔄 Modernize applications and test suites built around older X11 automation tools

🎬 Choreograph screen action for film, TV and stage — a character's typing and clicking, landing on cue

The desktop environments it can drive include, but may not be limited to:

GNOME (Mutter) and KDE Plasma (KWin)

Xfce and other X11 desktops, including the BSDs

sway , Hyprland and niri (the wlroots family)

Status: beta. Every capability is implemented on every backend that can support it. Much of it has been run against real GNOME, KDE, COSMIC, sway, Hyprland, niri, Xfce, X11, Debian, GhostBSD, Windows 10 and 11 and macOS sessions — every desktop listed above has now met a live session.

docs/validation.md records what each run covered, including what it could not cover.

Because desktops differ in what they permit, what a session can do is discovered at runtime rather than assumed — gui.supports(...) is how you ask, and docs/developers/design.md is why the API is shaped that way instead of being a one-to-one port.

New here? docs/getting-started.md is five minutes from nothing to a working script. docs/recipes.md answers "how do I…", and docs/troubleshooting.md answers "why didn't that work".

Prefer a book? Python Desktop Automation is a full-length companion to pyguitest and pyguitest-recorder — the desktop automation mindset, accessibility and toolkit differences, display servers, the recorder, and professional test practice. Free to read, pay what you want: leanpub.com/python-desktop-automation . The docs above remain authoritative for API detail; the book teaches the workflow.

What pyguitest is for

One Python API for driving an application that has no automation API of its own — a desktop program somebody else wrote, which you cannot add a test hook to. It works at the accessibility layer first, so a button is found by its role and name rather than by where it happens to be drawn, and falls back to coordinates only where a toolkit publishes nothing. That is the reason gui.supports() exists: the API does not promise everything works everywhere, it tells you what this session can do.

That shape decides what it is good at and what it is not:

Good at applications with no API of their own, tests that have to survive a redesign or a theme change, and working out why something is not being found on a desktop you do not control.

Not a test framework. It is a library: no pytest plugin, no fixtures, no runner. Use whatever you already use, and it will fit underneath it.

Not for browsers or mobile. Web pages have WebDriver and Playwright, phones have their own tooling. This drives desktop windows on Linux, the BSDs, Windows and macOS.

Not the first choice where the application can help. If a program ships a command line, a documented API or an in-app test hook, driving that is faster, more stable, and says what the test means instead of what it clicked. A toolkit's own test support is closer to the application than this can be.

Not a recorder. pyguitest-recorder is a separate package that writes pyguitest scripts from a recorded session, and pyguitest does not depend on it.

Requires Python 3.10 or newer.

Extras combine, and which ones you need depends on your desktop — pip install 'pyguitest[atspi,uinput]' is a common line on GNOME/KDE, pip install 'pyguitest[uinput]' is enough on COSMIC. See docs/install.md for what each desktop actually needs, or just run pyguitest doctor .

The AT-SPI libraries come from your distribution ( pyguitest doctor names them), so a virtualenv needs --system-site-packages to see them.

macOS asks for privacy grants (Accessibility, Screen Recording) in System Settings, and input is opt-in — see On macOS .

Or from a checkout, if you are working from the source tree:

You do not need -e ; that flag is for developing this package , and is covered in CONTRIBUTING.md .

None are required. The package imports and runs with nothing else installed. What you add depends on which backend has to serve your desktop — extras ( atspi , x11 , uinput , eiinput , windows , macos , dev ), a few distribution packages pip cannot supply, and sometimes a tool on PATH . Rather than work that out from a document, ask the machine:

It prints the exact commands — naming your distribution's packages on Linux and the BSDs, and answering in Windows terms on Windows. For the whole picture — a per-backend requirements matrix, the distribution package table, and how capture chooses a path — see docs/install.md . Injecting input has its own setup ( /dev/uinput permissions, the ydotool daemon, libei, portal consent): docs/input.md .

Which backend serves which part of a session. This is the shape of the answer, not a promise your machine: what a session actually assembled is what connect() reports, what backend.providers() lists, and what pyguitest doctor prints.

Two things the table cannot say. Whether an application publishes anything to its accessibility layer is up to the application; testable-guis.md is written for its developers. And which of these paths has been run against a real desktop, on which versions, is recorded in docs/validation.md . The Windows and macOS rows in particular have been exercised on few machines so far — one Windows 10 and one Windows 11 desktop, one macOS 26 machine — so read the table as what is implemented and validation.md as what has been measured. ADR 003 and ADR 004 record each platform's design.

Much of what validation.md records comes from one deliberately hostile test target: pyguitest-torture-test , a 702-widget Qt application built as the worst case for this library — 61 distinct widget classes and 95 and toolbar actions across nine tabs, every control carrying a stable accessible name, and a status bar that reports each action so a test can prove an interaction landed rather than assume it. Its 105 uniquely-named controls are each driven and status-bar-verified, plus the whole bar, across the Linux, BSD, Windows and macOS fleet — including the first widget-level drives on wlroots (Hyprland) and niri, sway having been exercised earlier for window control alone. The torture repo's VALIDATION.md holds the current per-platform matrix — the authoritative list of what is clean where, so this paragraph does not restate a count that would rot as the fleet grows. Every real bug those runs turned up in pyguitest itself is written up in validation.md , and every one of them is fixed.

Matching on role and name survives the application being moved or resized, unlike clicking at (842, 612) . elements() / element() take more than role and name -- enabled / visible filter on state, name / description take a compiled regex instead of an exact string, and predicate is an escape hatch for anything else (an ancestor/descendant check, say):

Ask before depending on anything that varies by desktop:

connect() never raises on a limited desktop — a session with few capabilities is the normal case, and supports() is how you find out. That includes macOS, where the grants are made by hand in System Settings: the backends are all composed by a plain connect() , and each reports a gated capability only where its grant is already there. Not everything there is gated — the window list, window geometry and activation, the screen list and the pointer position all come from CoreGraphics and need no grant at all — so supports() is worth asking rather than assuming a Mac with nothing granted can do nothing.

A session is usually several backends at once: elements from AT-SPI, injection from a CLI adapter, capture from another. CompositeBackend merges their capabilities and routes each call to whichever member provides it, so callers see one object. backend.providers() shows the routing.

region is (x, y, width, height) in screen coordinates — the same tuple gui.geometry(window) returns, on every backend. You never write a tool's own rectangle syntax; whichever tool the session picked gets its own built for it. window is served two ways, and the difference shows in the image: where the session serves WINDOW_CAPTURE the window's own pixels are read — its X11 drawable, PrintWindow on Windows, screencapture -l on macOS, or the GNOME Shell extension's own actor — so anything stacked on top of it is absent, and a window hanging off the edge of a display comes back whole; everywhere else, the Linux tools with no per-window mode among them, the rectangle is looked up and cut out of a full-screen shot, which does include whatever is covering it and does clip what is offscreen. gui.supports(Capability.WINDOW_CAPTURE) tells you which you are getting.

Automatically, when a test fails. Nothing captures on its own — a screenshot has to be taken while the failure is still propagating, because by the time an except: block runs the application under test is usually gone. Wrap the part you want documented:

Nothing is written when the block succeeds. On failure the image lands in artifacts/ (or $PYGUITEST_SCREENSHOT_DIR , or the temporary directory), its path is attached to the exception as .screenshot , and the original exception is re-raised untouched, so the test runner still reports the real failure. A screenshot that itself fails is recorded on the exception as .screenshot_error and swallowed — it never replaces the failure it was trying to document.

Runnable scripts in examples/ , each degrading with an explanation when the desktop cannot do what it asks:

Each also works as python -m pyguitest … , for when the pyguitest script is not on PATH .

pyguitest debug is what to paste into a bug report: package and Python versions, every environment probe (not only the ones that came back true), each detected tool's own --version , and whether the process is running inside a Flatpak, toolbox, or other container -- which changes what every other probe on this list actually sees. Add --json for a machine-readable form.

pyguitest inspect walks the accessible tree of every open window and prints it, grouped by application -- the tool for seeing what gui.button(...) or gui.element(role=..., name=...) actually has to match against, without writing a script first. --window TITLE_REGEX narrows it to one application; --json gives the same tree as machine-readable data, the same split debug uses.

The migration scanner reports the tier, the replacement and the line numbers of every call it recognizes in a Perl script -- both halves of qw(:ALL) , so the :CONST integers ( M_RIGHT is click(3) , M_UP a scroll(dy=1) detent) are explained alongside the 50 functions. Give it a directory and it walks the Perl sources under it; --json emits the same report as data. It exits non-zero on the two kinds of call a human has to decide rather than translate -- the ones Wayland refuses, and the two with no replacement anywhere -- so a port can be gated in CI.

pyguitest record is an alias for pyguitest-recorder , which records desktop activity and writes the pyguitest script for it. That tool is a separate package -- pyguitest does not depend on it, and installing pyguitest does not install it -- so the subcommand reports how to install it if it is absent. Everything after record is passed straight through, so pyguitest record --help is the recorder's own help and every one of its flags works unchanged.

docs/getting-started.md — five minutes to a working script, which API to reach for, and what X11, Wayland and XWayland each change

docs/recipes.md — task-shaped answers: waiting properly, forms, windows, screenshots, CI, and a cheat sheet for porting a Perl script

docs/troubleshooting.md — symptom first: nothing found, nothing typed, nothing captured

docs/api.md — the full API reference: every public class, method and enum, with the capability each one needs

docs/install.md — what each backend needs, per distribution, and how capture picks a path

docs/input.md — injecting pointer and keyboard input: permissions, daemons, keymap safety, libei and the portal

docs/validation.md — what has been run against a real desktop, and what has not

docs/ai-assistants.md — rules for a coding assistant generating pyguitest code

testable-guis.md — how to build a GUI that can be tested at all: the accessibility work that lets a test name a button instead of clicking a coordinate. Written to be handed to application developers; lives in the recorder repository

Design and internals — docs/developers/ : why the API is not a port, the audit of the 50 exports it derives from, the four ADRs, the repository structure, and the protocol gaps worth taking upstream.

Tests, lint, types, CI and the D-Bus suite: CONTRIBUTING.md .

GPL-2.0-or-later. See LICENSE .

Release files for pyguitest 0.30.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation .

Source distribution (sdist)

Built distribution (wheel)

Total release size: 3.0 MB

Release files / pyguitest-0.30.0.tar.gz

Provenance describes where a file came from. On PyPI, provenance is shared via attestations , which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 27, 2026.

Release files / pyguitest-0.30.0-py3-none-any.whl

Provenance describes where a file came from. On PyPI, provenance is shared via attestations , which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 27, 2026.

Security for pyguitest 0.30.0

Provenance describes where a file came from. On PyPI, provenance is shared via attestations , which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Both files in this release have been uploaded with provenance metadata.

Attestation for pyguitest-0.30.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 27, 2026.

Attestation for pyguitest-0.30.0-py3-none-any.whl

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 27, 2026.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Release history Release notifications | RSS feed

Nov 27, 2026 2 release files Full provenance

Nov 25, 2026 2 release files Full provenance

Nov 24, 2026 2 release files Full provenance

Nov 21, 2026 2 release files Full provenance

Nov 20, 2026 2 release files Full provenance

Nov 14, 2026 2 release files Full provenance

Nov 12, 2026 2 release files Full provenance

Nov 7, 2026 2 release files Full provenance

Nov 6, 2026 2 release files Full provenance

Nov 6, 2026 2 release files Full provenance

Nov 5, 2026 2 release files Full provenance

Nov 3, 2026 2 release files Full provenance

Nov 2, 2026 2 release files Full provenance

Oct 31, 2026 2 release files Full provenance

Oct 29, 2026 2 release files Full provenance

Oct 21, 2026 2 release files Full provenance

Oct 16, 2026 2 release files Full provenance

Oct 16, 2026 2 release files Full provenance

Oct 14, 2026 2 release files Full provenance

Oct 6, 2026 2 release files Full provenance

Oct 3, 2026 2 release files Full provenance

Oct 1, 2026 2 release files Full provenance

Sep 30, 2026 2 release files Full provenance

Sep 29, 2026 2 release files Full provenance

Sep 27, 2026 2 release files Full provenance

Sep 27, 2026 2 release files Full provenance

Sep 25, 2026 2 release files Full provenance

Sep 23, 2026 2 release files Full provenance

Sep 13, 2026 2 release files Full provenance

Sep 13, 2026 2 release files Full provenance

Sep 12, 2026 2 release files Full provenance

Sep 11, 2026 2 release files Full provenance

Sep 9, 2026 2 release files Full provenance

Sep 8, 2026 2 release files Full provenance

Sep 6, 2026 2 release files Full provenance

Sep 5, 2026 2 release files Full provenance

Sep 5, 2026 2 release files Full provenance

Sep 1, 2026 2 release files Full provenance

Aug 30, 2026 2 release files Full provenance

Aug 30, 2026 2 release files Full provenance

Extracted Entities