A simple UI testing framework for macOS
Project description
MacUITest
A simple framework that helps to create functional and UI tests against almost any macOS application.
- Created to help testers to automate their routine tasks with ease and help me with structuring my experience;
- I'll be glad to receive suggestions on evolution of the project!
Tips
- Allow Accessibility access in a Security&Privacy pane of System Preferences;
- You might be asked to allow various access rights anyway, those are new macOS restrictions you cannot easily avoid from Python, just allow them;
- When calling ObjC mouse wrapper a Python Launcher will show up in Dock. To avoid this behavior, you need to add
LSUIElement-string "1"to a Python.app property list. Mine was located easily by runningbrew --prefix python3. It'll be under Frameworks -> Python.framework -> Resources; - Get UI Browser app, it helps to locate AppleScript locators of the elements on your screen, very helpful;
Table of Contents
Installation
- Install a modern Python version (at least 3.6):
brew install python3 - If OCR capabilities required, install Tesseract:
brew install tesseract - Update pip's setup tools:
pip3 install --upgrade pip setuptools wheel - Install the package:
pip3 install macuitestand you should be ready to go
Features
- Many of useful operations on macOS are introduced in a
macuitest.lib.operating_systempackage. Amacosmodule inside the package will allow you to manipulate files, processes, change some system settings, etc.; - An
applicationmodule insidemacuitest.lib.appsmay describe almost any GUI macOS app. Creating an instance of which will allow you to perform launch/quit operations, read some of its attributes, have basic control over its main window, etc.; applescript_wrappermodule undermacuitest.lib.applescript_liballows to run some AppleScript commands;- And last but not least, you can describe most if not every element of an application using
applescript_element,native_elementandui_elementmodules insidemacuitest.lib.elements. They allow working with AppleScript, PyObjC translated (Native) and UI (built on screenshots) elements retrospectively.
Examples
from macuitest.lib.apps.application import Application
from macuitest.lib.elements.applescript_element import ASElement
test_app = 'Calculator'
calculator = Application(test_app)
button_one = ASElement('button "1" of group 2 of window 1', process=test_app)
button_zero = ASElement('button "0" of group 2 of window 1', process=test_app)
input_field = ASElement('static text 1 of group 1 of window 1', process=test_app)
calculator.launch()
button_one.click_mouse()
button_zero.click_mouse()
button_one.click_mouse()
assert input_field.text == '101' # Hopefully you get 101 there :)
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
macuitest-0.7.43.tar.gz
(64.1 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file macuitest-0.7.43.tar.gz.
File metadata
- Download URL: macuitest-0.7.43.tar.gz
- Upload date:
- Size: 64.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
97cf4301755fa8c931f7e353eae433cd1521559ab945acb71edc35820cfc63d3
|
|
| MD5 |
54df1af2659044227e36c447b2a77e60
|
|
| BLAKE2b-256 |
61403f561ced77db011bdd1455a9edef7b9ccec177cb4a4f29b0b69fffe9c6db
|
File details
Details for the file macuitest-0.7.43-py3-none-any.whl.
File metadata
- Download URL: macuitest-0.7.43-py3-none-any.whl
- Upload date:
- Size: 76.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9dfb191bc06d0d8e9e3e80d0145e1ee54d4527f10be62b9e77691fa4ffac28c9
|
|
| MD5 |
4ef91169d597204a7ed0dccad1deac50
|
|
| BLAKE2b-256 |
e3a4a6d0b25bbe4b080269c1b1a4053e940dee2f86a2926b8bc391b8242d797c
|