Robot Framework Self-Healing Library for automated test maintenance
Reason this release was yanked:
for making it private
Project description
Robot Framework Self-Healing Library
๐ค Automated test maintenance for Robot Framework + Selenium
A powerful self-healing library that automatically detects and fixes broken locators in Robot Framework tests, reducing maintenance overhead and improving test reliability.
โจ Features
- ๐ง Automatic Locator Healing: Detects failed locators and suggests fixes using AI
- ๐ฏ Smart Candidate Generation: Analyzes DOM to find alternative locators
- ๐ง AI-Powered Solutions: Uses OpenAI GPT-4 for intelligent locator suggestions
- ๐ Detailed Reporting: Comprehensive healing reports in test results
- ๐ Seamless Integration: Works transparently with existing Robot Framework tests
- ๐ Code Updates: Automatically updates PageObject files with healed locators
๐ Installation
From PyPI (Recommended)
pip install robot-selfheal
From Source
git clone https://github.com/samarthindex9/selfhealing_library.git
cd selfhealing_library
pip install -e .
โ๏ธ Setup
1. Environment Configuration
Create an .env file in your Environment directory:
# Environment/.env
OPENAI_API_KEY=your_openai_api_key_here
2. Configuration File
Create Environment/config.json:
{
"data_path": "locator_data",
"page_objects_dir": "PageObjects",
"page_sources_dir": "locator_data/page_sources",
"results_dir": "results",
"locator_data": {
"healing_prompts": "healing_prompts.json",
"healed_locators": "healed_locators.json",
"locator_failures": "locator_failures.json"
}
}
๐ Usage
Method 1: Import as Library (Recommended)
Add to your Robot Framework test file:
*** Settings ***
Library robot_selfheal.SelfHealListener
*** Test Cases ***
Your Test Case
[Documentation] Your test with automatic self-healing
Open Browser https://example.com chrome
Click Element ${BROKEN_LOCATOR} # Will auto-heal if it fails
Close Browser
Method 2: Listener Mode
Run your tests with the listener:
robot --listener robot_selfheal.SelfHealListener your_test.robot
Method 3: Command Line Integration
# Run tests with self-healing enabled
robot-selfheal --suite your_test_suite --browser chrome
๐๏ธ Project Structure
Your Robot Framework project should follow this structure:
your_project/
โโโ Environment/
โ โโโ config.json # Configuration file
โ โโโ .env # OpenAI API key
โโโ PageObjects/ # Page object files with locators
โ โโโ login_page.py
โ โโโ dashboard_page.py
โโโ TestCases/ # Your test cases
โ โโโ login_tests.robot
โโโ results/ # Test results and reports
๐ง Configuration Options
The config.json file supports these options:
| Option | Description | Default |
|---|---|---|
data_path |
Directory for healing data | "locator_data" |
page_objects_dir |
PageObjects directory | "PageObjects" |
page_sources_dir |
HTML captures directory | "locator_data/page_sources" |
results_dir |
Test results directory | "results" |
๐ How It Works
- Detection: Monitors test execution for locator failures
- Analysis: Captures page source and analyzes DOM structure
- Generation: Creates candidate alternative locators using smart algorithms
- AI Enhancement: Uses OpenAI GPT-4 to select best healing solution
- Application: Updates PageObject files with healed locators
- Reporting: Adds healing summary to test reports
๐ฏ Supported Locator Types
- โ
XPath expressions (
//div[@id='example']) - โ
CSS selectors (
css=.my-class) - โ
ID locators (
id=my-element) - โ
Name locators (
name=my-input) - โ
Class locators (
class=my-class) - โ
Text-based locators (
//*[contains(text(), 'Click Me')])
๐ Example Output
When a locator fails, the library generates a detailed healing report:
๐ง Self-Healing Summary
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Variable: ${LOGIN_BUTTON} โ
โ Source: login_page.py โ
โ Original: //button[@id='old-login-btn'] โ
โ Healed: //button[@data-testid='login-submit'] โ
โ Solution: Updated to use more stable data-testid โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
๐ง Advanced Configuration
Custom Candidate Generation
from robot_selfheal import generate_enhanced_candidates
# Generate candidates with custom settings
candidates = generate_enhanced_candidates(
locator="//button[@id='broken']",
mode="lenient", # strict, balanced, lenient
threshold=60 # similarity threshold
)
Programmatic Healing
from robot_selfheal import SelfHealingAgent
agent = SelfHealingAgent()
healed_data = agent.heal_locator("//broken[@locator='value']")
๐ค Contributing
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
๐ License
This project is licensed under the MIT License - see the LICENSE file for details.
๐โโ๏ธ Support
- ๐ง Contact:
- Project Manager: samarth.math@indexnine.com
- Development Team: vikas.gupta@indexnine.com, onkar.pawar@indexnine.com
- ๐ Issues: GitHub Issues
- ๐ Documentation: Wiki
๐ Acknowledgments
- Project Team:
- Samarth Math - Project Manager
- Vikas Gupta - Developer
- Onkar Pawar - Developer
- Robot Framework community for the excellent testing framework
- Selenium WebDriver for web automation capabilities
- OpenAI for providing the GPT-4 API
- BeautifulSoup and lxml for HTML parsing capabilities
Made with โค๏ธ for the Robot Framework community
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 robot_selfheal-2.1.0.tar.gz.
File metadata
- Download URL: robot_selfheal-2.1.0.tar.gz
- Upload date:
- Size: 42.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
95485ab40744e4ba90efe134c6992ebe523461ec0cf462f687a1056d8896dc60
|
|
| MD5 |
e1ed1494835767fcb235df11f11f0ce5
|
|
| BLAKE2b-256 |
c3ed078c6ea67e020818949fedd4dc0e7d1f75d9b8b06dd6aa18fa4d679e26f8
|
File details
Details for the file robot_selfheal-2.1.0-py3-none-any.whl.
File metadata
- Download URL: robot_selfheal-2.1.0-py3-none-any.whl
- Upload date:
- Size: 40.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8d353d3a079cf96662831fa3a04f4136d43079d07424333bd234ded6679f8f27
|
|
| MD5 |
f5b91ceb66152424d38cc599e8bb37e0
|
|
| BLAKE2b-256 |
fd2aa31d748069b140b2aec7b58ee462f68cd96aecc7a73380730d36f488cdce
|