Skip to main content

A flexible and modular test automation framework that can be used to automate any mobile application.

Project description

Optics Framework

Quality Gate Status License Python Code Smells Coverage OpenSSF Best Practices

Optics Framework is a powerful, extensible no code test automation framework designed for vision powered, data-driven testing and production app synthetic monitoring. It enables seamless integration with intrusive action & detection drivers such as Appium / WebDriver as well as non-intrusive action drivers such as BLE mouse / keyboard and detection drivers such as video capture card and external web cams.

This framework was designed primarily for the following use cases:

  1. Production app monitoring where access to USB debugging / developer mode and device screenshots is prohibited
  2. Resilient self-healing test automation that rely on more than one element identifier and multiple fallbacks to ensure maximum recovery
  3. Enable non-coders to build test automation scripts

๐Ÿš€ Features

  • Vision powered detections: UI object detections are powered by computer vision and not just on XPath elements.
  • No code automation: No knowledge of programming languages or access to IDE needed to build automations scripts
  • Supports non-intrusive action drivers: Non-intrusive action drivers such as BLE mouse and keyboard are supported
  • Data-Driven Testing (DDT): Execute test cases dynamically with multiple datasets, enabling parameterized testing and iterative execution.
  • Extensible & Scalable: Easily add new keywords and modules without any hassle.
  • AI Integration: Choose which AI models to use for object recognition and OCR.
  • Self-healing capability: Configure multiple drivers, screen capture methods, and detection techniques with priority-based execution. If a primary method fails, the system automatically switches to the next available method in the defined hierarchy

๐Ÿ“ฆ Installation

Install via pip

pip install optics-framework

๐Ÿš€ Quick Start

1 Install Optics Framework

Note: Ensure Appium server is running and a virtual Android device is enabled before proceeding.

mkdir ~/test-code
cd ~/test-code
python3 -m venv venv
source venv/bin/activate
pip install optics-framework

โš ๏ธ Important: Conda environments are not supported for easyocr and optics-framework together, due to conflicting requirements for numpy (version 1.x vs 2.x). Please use a standard Python virtual environment instead.

2 Create a New Test Project

optics setup --install Appium EasyOCR
optics init --name my_test_project --path . --template contact

๐Ÿ“Œ Dry Run Test Cases

optics dry_run my_test_project

๐Ÿ“Œ Execute Test Cases

optics execute my_test_project

๐Ÿ› ๏ธ Usage

Execute Tests

optics execute <project_name>

Initialize a New Project

optics init --name <project_name> --path <directory> --template <contact/youtube> --force

List Available Keywords

optics list

Display Help

optics --help

Check Version

optics version

๐Ÿ—๏ธ Developer Guide

Project Structure

Optics_Framework/
โ”œโ”€โ”€ LICENSE
โ”œโ”€โ”€ README.md
โ”œโ”€โ”€ dev_requirements.txt
โ”œโ”€โ”€ samples/            # Sample test cases and configurations
|   โ”œโ”€โ”€ contact/
|   โ”œโ”€โ”€ youtube/
โ”œโ”€โ”€ pyproject.toml
โ”œโ”€โ”€ tox.ini
โ”œโ”€โ”€ docs/               # Documentation using Sphinx
โ”œโ”€โ”€ optics_framework/   # Main package
โ”‚   โ”œโ”€โ”€ api/            # Core API modules
โ”‚   โ”œโ”€โ”€ common/         # Factories, interfaces, and utilities
โ”‚   โ”œโ”€โ”€ engines/        # Engine implementations (drivers, vision models, screenshot tools)
โ”‚   โ”œโ”€โ”€ helper/         # Configuration management
โ”œโ”€โ”€ tests/              # Unit tests and test assets
โ”‚   โ”œโ”€โ”€ assets/         # Sample images for testing
โ”‚   โ”œโ”€โ”€ units/          # Unit tests organized by module
โ”‚   โ”œโ”€โ”€ functional/     # Functional tests organized by module

Available Keywords

The following keywords are available and organized by category. These keywords can be used directly in your test cases or extended further for custom workflows.

๐Ÿ”น Core Keywords
  • Clear Element Text (element, event_name=None)
    Clears any existing text from the given input element.
  • Detect and Press (element, timeout, event_name=None)
    Detects if the element exists, then performs a press action on it.
  • Enter Number (element, number, event_name=None)
    Enters a numeric value into the specified input field.
  • Enter Text (element, text, event_name=None)
    Inputs the given text into the specified element.
  • Get Text (element)
    Retrieves the text content from the specified element.
  • Press by Coordinates (x, y, repeat=1, event_name=None)
    Performs a tap at the specified absolute screen coordinates.
  • Press by Percentage (percent_x, percent_y, repeat=1, event_name=None)
    Taps on a location based on percentage of screen width and height.
  • Press Element (element, repeat=1, offset_x=0, offset_y=0, event_name=None)
    Taps on a given element with optional offset and repeat parameters.
  • Press Element with Index (element, index=0, event_name=None)
    Presses the element found at the specified index from multiple matches.
  • Press Keycode (keycode, event_name)
    Simulates pressing a hardware key using a keycode.
  • Scroll (direction, event_name=None)
    Scrolls the screen in the specified direction.
  • Scroll from Element (element, direction, scroll_length, event_name)
    Scrolls starting from a specific element in the given direction.
  • Scroll Until Element Appears (element, direction, timeout, event_name=None)
    Continuously scrolls until the target element becomes visible or the timeout is reached.
  • Select Dropdown Option (element, option, event_name=None)
    Selects an option from a dropdown field by visible text.
  • Sleep (duration)
    Pauses execution for a specified number of seconds.
  • Swipe (x, y, direction='right', swipe_length=50, event_name=None)
    Swipes from a coordinate point in the given direction and length.
  • Scroll from Element (element, direction, scroll_length, event_name)
    Scrolls starting from the position of a given element.
  • Swipe Until Element Appears (element, direction, timeout, event_name=None)
    Swipes repeatedly until the element is detected or timeout is reached.
๐Ÿ”น AppManagement
  • Close And Terminate App(package_name, event_name)
    Closes and fully terminates the specified application using its package name.
  • Force Terminate App(event_name)
    Forcefully terminates the currently running application.
  • Get App Version
    Returns the version of the currently running application.
  • Initialise Setup
    Prepares the environment for performing application management operations.
  • Launch App (event_name=None)
    Launches the default application configured in the session.
  • Start Appium Session (event_name=None)
    Starts a new Appium session for the current application.
  • Start Other App (package_name, event_name)
    Launches a different application using the provided package name.
๐Ÿ”น FlowControl
  • Condition
    Evaluates multiple conditions and executes corresponding modules if the condition is true.
  • Evaluate (param1, param2)
    Evaluates a mathematical or logical expression and stores the result in a variable.
  • Read Data (input_element, file_path, index=None)
    Reads data from a CSV file, API URL, or list and assigns it to a variable.
  • Run Loop (target, *args)
    Runs a loop either by count or by iterating over variable-value pairs.
๐Ÿ”น Verifier
  • Assert Equality (output, expression)
    Compares two values and checks if they are equal.
  • Assert Images Vision (frame, images, element_status, rule)
    Searches for the specified image templates within the frame using vision-based template matching.
  • Assert Presence (elements, timeout=30, rule='any', event_name=None)
    Verifies the presence of given elements using Appium or vision-based fallback logic.
  • Assert Texts Vision (frame, texts, element_status, rule)
    Searches for text in the given frame using OCR and updates element status.
  • Is Element (element, element_state, timeout, event_name)
    Checks if a given element exists.
  • Validate Element (element, timeout=10, rule='all', event_name=None)
    Validates if the given element is present on the screen using defined rule and timeout.
  • Validate Screen (elements, timeout=30, rule='any', event_name=None)
    Validates the presence of a set of elements on a screen using the defined rule.
  • Vision Search (elements, timeout, rule)
    Performs vision-based search to detect text or image elements in the screen.

Setup Development Environment

git clone git@github.com:mozarkai/optics-framework.git
cd Optics_Framework
pipx install poetry
poetry install --with dev

Running Tests

poetry install --with tests
poetry run pytest

Build Documentation

poetry install --with docs
poetry run mkdocs serve

Packaging the Project

poetry build

๐Ÿ“œ Contributing

We welcome contributions! Please follow these steps:

  1. Fork the repository.
  2. Create a new feature branch.
  3. Commit your changes.
  4. Open a pull request.

Ensure your code follows PEP8 standards and is formatted with Black.


๐ŸŽฏ Roadmap

Here are the key initiatives planned for the upcoming quarter:

  1. MCP Servicer: Introduce a dedicated service to handle MCP (Model Context Protocol), improving scalability and modularity across the framework.
  2. Omniparser Integration: Seamlessly integrate Omniparser to enable robust and flexible element extraction and location.
  3. Playwright Integration: Add support for Playwright to enhance browser automation capabilities, enabling cross-browser testing with modern and powerful tooling.
  4. Audio Support: Extend the framework to support audio inputs and outputs, enabling testing and verification of voice-based or sound-related interactions.

๐Ÿ“„ License

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


๐Ÿ“ž Support

For support, please open an issue on GitHub or contact us at [@malto101], [@davidamo9] or [lalit@mozark.ai] .

Happy Testing! ๐Ÿš€

Project details


Release history Release notifications | RSS feed

Download files

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

Source Distribution

optics_framework-1.7.1.tar.gz (291.2 kB view details)

Uploaded Source

Built Distribution

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

optics_framework-1.7.1-py3-none-any.whl (413.7 kB view details)

Uploaded Python 3

File details

Details for the file optics_framework-1.7.1.tar.gz.

File metadata

  • Download URL: optics_framework-1.7.1.tar.gz
  • Upload date:
  • Size: 291.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.1 CPython/3.13.7 Darwin/25.0.0

File hashes

Hashes for optics_framework-1.7.1.tar.gz
Algorithm Hash digest
SHA256 f36f4cbbaa1158ce6bda6472c58f8b1228bd3f3ab95d5f6cf8ef175f560feded
MD5 6e7981be35812ed080216bb17299a35e
BLAKE2b-256 429bf118bd09b85c60eb0acf928b604ad30c094be5244141fa8ac8e34933f466

See more details on using hashes here.

File details

Details for the file optics_framework-1.7.1-py3-none-any.whl.

File metadata

  • Download URL: optics_framework-1.7.1-py3-none-any.whl
  • Upload date:
  • Size: 413.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.1 CPython/3.13.7 Darwin/25.0.0

File hashes

Hashes for optics_framework-1.7.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ca128865ea5a91d87bde73d555321005ef9cabf2f1461b4d5d8db8c82421f1bb
MD5 003a376a2b0513170eed025807706d74
BLAKE2b-256 9ce6bf80815bc7df560dc9ed1ddd8de604bad4362b15ed2f3ad3ce04f4bc2082

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