A flexible and modular test automation framework that can be used to automate any mobile application.
Project description
Optics Framework
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:
- Production app monitoring where access to USB debugging / developer mode and device screenshots is prohibited
- Resilient self-healing test automation that rely on more than one element identifier and multiple fallbacks to ensure maximum recovery
- 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 --index-url https://pypi.org/simple/ --extra-index-url https://test.pypi.org/simple/ optics-framework
๐ Quick Start
1 Create a New Test Project
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 --index-url https://pypi.org/simple/ --extra-index-url https://test.pypi.org/simple/ optics-framework
2 Create a New Test Project
optics init --name my_test_project --path . --template youtube
๐ 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> --test-cases <test_case_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. -
swipe_from_element(element, direction, swipe_length, event_name=None)
Swipes 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
-
_compute_expression(param2)
Resolves variables and safely computes a mathematical or logical expression. -
_ensure_runner()
Internal method to ensure a valid runner is set before execution. -
_evaluate_conditions(pairs, else_target)
Evaluates a list of condition-target pairs and executes the first matched one. -
_extract_element_name(input_element)
Extracts the variable name from a Robot-style input (e.g., ${var}). -
_extract_variable_name(param1)
Extracts a variable name from a string and strips formatting. -
_is_condition_true(condition)
Resolves variables and safely evaluates a condition string. -
_load_data(file_path, index=None)
Loads data from a local CSV, API response, or list for use in test steps. -
_loop_by_count(target, count)
Executes a module a specified number of times. -
_loop_with_variables(target, args)
Loops over multiple sets of variables and values to execute a module with dynamic input. -
_parse_iterables(variables, iterables)
Parses raw iterable strings or lists into structured Python lists. -
_parse_single_iterable(iterable, variable)
Parses a single iterable string or list and validates its structure. -
_parse_variable_iterable_pairs(variables, iterables)
Parses variables and iterable values into matched pairs. -
_parse_variable_names(variables)
Extracts variable names from Robot Framework-style variable syntax. -
_resolve_condition(condition)
Substitutes variables in a condition string with their values. -
_safe_eval(expression)
Evaluates expressions securely with limited allowed operations and types. -
_split_condition_args(args)
Separates condition-target pairs and an optional else-target from arguments. -
condition(*args)
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. -
execute_module(module_name)
Executes all the steps defined in the specified module. -
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 sphinx-build -b html docs/ docs/_build/
Packaging the Project
poetry build
๐ Contributing
We welcome contributions! Please follow these steps:
- Fork the repository.
- Create a new feature branch.
- Commit your changes.
- 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:
- MCP Servicer: Introduce a dedicated service to handle MCP (Model Context Protocol), improving scalability and modularity across the framework.
- Omniparser Integration: Seamlessly integrate Omniparser to enable robust and flexible element extraction and location.
- Playwright Integration: Add support for Playwright to enhance browser automation capabilities, enabling cross-browser testing with modern and powerful tooling.
- 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
:TODO: Add support information
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
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 optics_framework-1.0.0.tar.gz.
File metadata
- Download URL: optics_framework-1.0.0.tar.gz
- Upload date:
- Size: 97.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.1 CPython/3.13.2 Darwin/24.4.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
133c5be800bfd262a67d56782cff5a859c7c2cbf103948784aa8789b4fa69018
|
|
| MD5 |
7b6bf8385cdcbd22902c6f7314827a50
|
|
| BLAKE2b-256 |
85cdf96e0022ca58b87e70d69c52fd8f8cb4b46bb51415e82ba3620548c177e5
|
File details
Details for the file optics_framework-1.0.0-py3-none-any.whl.
File metadata
- Download URL: optics_framework-1.0.0-py3-none-any.whl
- Upload date:
- Size: 124.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.1 CPython/3.13.2 Darwin/24.4.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
efe5fd2cd4aabd38ef836d1730c1c48d5ec68586925e6b8602d2394fbf88770f
|
|
| MD5 |
7ab1d58b73155d79193ed42b2665c9d5
|
|
| BLAKE2b-256 |
e88a4978901c92595956e040a79bfb2f472b0cd1a0a7fd8a3a1a65e43285ff9d
|