Skip to main content

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

  1. Detection: Monitors test execution for locator failures
  2. Analysis: Captures page source and analyzes DOM structure
  3. Generation: Creates candidate alternative locators using smart algorithms
  4. AI Enhancement: Uses OpenAI GPT-4 to select best healing solution
  5. Application: Updates PageObject files with healed locators
  6. 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

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

๐Ÿ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

๐Ÿ™‹โ€โ™‚๏ธ Support

๐Ÿ† 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


Download files

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

Source Distribution

robot_selfheal-2.0.1.tar.gz (43.3 kB view details)

Uploaded Source

Built Distribution

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

robot_selfheal-2.0.1-py3-none-any.whl (41.4 kB view details)

Uploaded Python 3

File details

Details for the file robot_selfheal-2.0.1.tar.gz.

File metadata

  • Download URL: robot_selfheal-2.0.1.tar.gz
  • Upload date:
  • Size: 43.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.5

File hashes

Hashes for robot_selfheal-2.0.1.tar.gz
Algorithm Hash digest
SHA256 a329eac6f80a491df730ce3cace6b7d17044c66918b53bb552be36bd1d771ea9
MD5 b96c70b1435a92235231dbfdcd7c6fa7
BLAKE2b-256 f547065f472b15572aeb72d38b59ab84de980ea7f0e3fb0fae952c5b64bab8ea

See more details on using hashes here.

File details

Details for the file robot_selfheal-2.0.1-py3-none-any.whl.

File metadata

  • Download URL: robot_selfheal-2.0.1-py3-none-any.whl
  • Upload date:
  • Size: 41.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.5

File hashes

Hashes for robot_selfheal-2.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 305d0511bb8fd6128587fe7a337ee477f7cc2da7987dd5533f5c9496185c4fb2
MD5 939010e500fb921272ec34e46e249b4a
BLAKE2b-256 305c7c329e286f14ffcbc21ce77edba3a0ab8c6436fa324a061b3829428b1caf

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