Skip to main content

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 me 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 running brew --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 the package: pip3 install macuitest and you should be ready to go

Features

  • Many of useful operations on macOS are introduced in a macuitest.lib.operating_system package. A macos module inside the package will allow you to manipulate files, processes, change some of system settings, etc.;
  • An application module inside macuitest.lib.apps may 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_wrapper module under macuitest.lib.applescript_lib allows 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_element and ui_element modules inside macuitest.lib.elements. They describe allow to work 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.40.tar.gz (60.2 kB view details)

Uploaded Source

File details

Details for the file macuitest-0.7.40.tar.gz.

File metadata

  • Download URL: macuitest-0.7.40.tar.gz
  • Upload date:
  • Size: 60.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.1 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.9.0

File hashes

Hashes for macuitest-0.7.40.tar.gz
Algorithm Hash digest
SHA256 dab036db3087a603356a0286d2c097f3d88fbf903d4a94a33d41988f090be22f
MD5 1d0998a58271abaa64a7999692a6ad73
BLAKE2b-256 4417e70c75e3b562b97b378cfe77c92382f46e0cfc8f5a29305b9a2f6ad051b9

See more details on using hashes here.

Supported by

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