Skip to main content

A unified Robot Framework library for testing Qt applications via Agent or Accessibility APIs.

Project description

robotframework-qtexpert

A unified Robot Framework library for testing Qt applications. It provides a powerful and flexible API to automate your GUIs, whether they are open-source or closed-source, running on Linux, Windows, or macOS.

This library uniquely supports two distinct approaches to automation, allowing you to choose the best tool for your specific use case.

Key Features

  • Dual-Mode Operation: Choose between the powerful Agent Mode or the non-invasive Accessibility Mode.
  • Cross-Platform: Test your applications on Windows, Linux, and macOS with a single test suite.
  • Unified API: The same keywords work regardless of the backend mode or operating system.
  • Backward Compatible: Agent mode supports multiple Qt bindings (PyQt5/6, PySide2/6).
  • Robot Framework Native: Seamlessly integrates with your existing Robot Framework test infrastructure.

The Core Concept: Agent vs. Accessibility

The fundamental challenge in GUI automation is that your test script runs in a different process than your application. This library solves this in two different ways.

1. Agent Mode (The "In-Process" Approach)

In this mode, a tiny agent server is started inside your application's process. The library (the client) communicates with this agent over a local network connection.

How it Works: You add a few lines of code to your application to start the agent. The agent has full, direct access to all Qt objects. The library sends commands like "click button X" to the agent, which executes them using the real Qt API.

Pros:

  • Extremely Reliable: Direct access to the Qt object model.
  • Full Power: Can access any Qt property or method.
  • Stable Locators: Uses Qt's objectName, which is the most reliable way to identify elements.

Cons:

  • Minimal Integration: Requires a small, conditional code change in the application under test.

Best For: Applications you are building yourself or where you can influence the source code.

2. Accessibility (A11y) Mode (The "OS-Level" Approach)

This mode uses the operating system's native accessibility APIs, which are designed for tools like screen readers.

How it Works: The library connects to your application as an external assistive technology. It inspects the application's accessibility tree to find buttons, text fields, and other controls.

Pros:

  • No Code Changes: Works with any application that has accessibility enabled (which is the default for most Qt apps).
  • Ideal for Closed-Source: Perfect for testing third-party applications where you cannot modify the code.

Cons:

  • Less Powerful: Limited to what the OS API exposes.
  • More Brittle: Locators like text or position can change more easily than an objectName.

Best For: Closed-source, third-party, or legacy applications where code integration is not possible.

Comparison Summary

Feature Agent Mode Accessibility Mode
Reliability Very High Medium
Power Full Qt API Access Limited to OS API
Locator Stability Excellent (objectName) Medium (Text, Control Type, Position)
Code Change Required? Minimal & Conditional None
Use Case Testable, open-source, or in-house apps Closed-source, third-party, or legacy apps

Installation

Install the library from PyPI:

pip install robotframework-qtexpert

You must also install the dependencies for the mode(s) you plan to use.

For Agent Mode

Choose one or more Qt bindings:

pip install robotframework-qtexpert[agent-pyqt6]
# or
pip install robotframework-qtexpert[agent-all]

For Accessibility Mode

Install the dependencies for your target OS:

# For Windows
pip install robotframework-qtexpert[a11y-windows]

# For Linux
pip install robotframework-qtexpert[a11y-linux]

# For macOS
pip install robotframework-qtexpert[a11y-macos]

For Everything (Recommended for Development)

pip install robotframework-qtexpert[all]

Quick Start & Usage Examples

Example 1: Using Agent Mode

Prerequisite: Your application must be set up to launch the agent. See the tests/test_app_agent/main.py file in this repository for a minimal example.

*** Settings ***
Library         qtexpert    mode=agent
Suite Teardown  Close Application

*** Variables ***
${APP_COMMAND}      python /path/to/your/agent_enabled_app.py
${PORT_FILE_PATH}   ${TEMPDIR}/qt_agent_port.txt

*** Test Cases ***
Test User Login With Agent
    # Launch the app. The library will wait for the agent to write its port to the file.
    Launch Application    ${APP_COMMAND}    port_file_path=${PORT_FILE_PATH}

    # Use the stable 'objectName' as a locator
    Input Text    username_field    testuser
    Input Text    password_field    password123
    Click Button    login_button

    # Verify the result
    Text Should Be    status_label    Login Successful!

Example 2: Using Accessibility Mode

Prerequisite: Your application must be accessible. This is the default for most standard Qt widgets.

*** Settings ***
Library         qtexpert    mode=a11y
Suite Teardown  Close Application

*** Variables ***
${APP_COMMAND}      C:/Program Files/MyQtApp/MyQtApp.exe
${WINDOW_TITLE}     MyQtApp Main Window

*** Test Cases ***
Test User Login With A11y
    # Launch the app. The library will find it by its window title.
    Launch Application    ${APP_COMMAND}    window_title=${WINDOW_TITLE}

    # Use visible text or control types as locators
    Input Text    Username    testuser
    Input Text    Password    password123
    Click Button    Login

    # Verify the result
    Text Should Be    Login Successful!    # Locates a label with this text

Keyword Reference

The library is organized into logical keyword groups:

  • Application: Launch Application, Close Application
  • Generic: Click Button, Input Text, Text Should Be

For a full list of keywords and their arguments, please refer to the Keyword Documentation.

Development & Publishing

To build the package for PyPI:

  1. Install build tools:
    pip install build twine
    
  2. Build the source distribution and wheel:
    python -m build
    
  3. Upload to PyPI (requires credentials):
    python -m twine upload dist/*
    

Contributing

Contributions are welcome! If you have a bug report, feature request, or want to submit a pull request, please visit our GitHub Issues page.

For major changes, please open an issue first to discuss what you would like to change.

Please ensure you add tests for any new features and that all existing tests pass.

License

This project is licensed under the Apache License 2.0 - see the LICENSE file for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

robotframework_qtexpert-0.1.1.tar.gz (17.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

robotframework_qtexpert-0.1.1-py3-none-any.whl (17.7 kB view details)

Uploaded Python 3

File details

Details for the file robotframework_qtexpert-0.1.1.tar.gz.

File metadata

  • Download URL: robotframework_qtexpert-0.1.1.tar.gz
  • Upload date:
  • Size: 17.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for robotframework_qtexpert-0.1.1.tar.gz
Algorithm Hash digest
SHA256 af96f25009b42570761cd216c1d3239183115e6ae0cab6e8080533d0a9eb4890
MD5 fca868500e21364800605bf664e7a6a1
BLAKE2b-256 b60dad8bff1dabe29ebe9a4f098b394a09447e5c452b61989ef8a578d0708b10

See more details on using hashes here.

File details

Details for the file robotframework_qtexpert-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for robotframework_qtexpert-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 8ed9468c0810033e151823f4c110141dbcfd56249ffa7d36433acbf84054e0e7
MD5 ee1cad72057b32437b34c823812c2dbe
BLAKE2b-256 10954455c56ff804446619cf970bb8718369109e5b2ad5a4983f6cc6cd0ce1e9

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page