Metadata-Version: 2.1
Name: robotframework-heal
Version: 0.2.1
Summary: A Robot Framework Listener for library agnostic self-healing and smart recovery of tests
Home-page: https://github.com/manykarim/robotframework-heal
License: Apache-2.0
Author: Many Kasiriha
Author-email: many.kasiriha@dbschenker.com
Maintainer: Many Kasiriha
Maintainer-email: many.kasiriha@dbschenker.com
Requires-Python: >=3.10,<4.0
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Requires-Dist: beautifulsoup4
Requires-Dist: cssify
Requires-Dist: jinja2
Requires-Dist: litellm
Requires-Dist: lxml
Requires-Dist: opencv-python-headless
Requires-Dist: parsimonious
Requires-Dist: pyautogui
Requires-Dist: python-dotenv
Requires-Dist: robotframework
Requires-Dist: robotframework-appiumlibrary
Requires-Dist: robotframework-browser
Requires-Dist: thefuzz
Requires-Dist: tinydb
Description-Content-Type: text/markdown

# robotframework-heal
A Robot Framework Listener for library agnostic self-healing and smart recovery of tests

📙 [Documentation](https://manykarim.github.io/robotframework-heal/) can be found [here](https://manykarim.github.io/robotframework-heal/)

## Installation
```bash
pip install robotframework-heal
```

## Usage

Add `Library    SelfHealing ` to your Robot Framework test suite `*** Settings ***` section.

```robotframework
*** Settings ***
Library    SelfHealing
```	

Set up the following environment variables to enable the self-healing feature:

* `LLM_API_KEY`
* `LLM_API_BASE`
* `LLM_TEXT_MODEL` (model used for picking final locator from proposal list)
* `LLM_LOCATOR_MODEL` (model for generating locator proposals from DOM tree)
* `LLM_VISION_MODEL` (not working yet)

Interface with LLMs uses the [LiteLMM](https://docs.litellm.ai) API.  
Check the list of available [Providers](https://docs.litellm.ai/docs/providers) and how to connect to them.  

```robotframework
*** Settings ***
Library    Browser    timeout=5s
Library    SelfHealing    use_llm_for_locator_proposals=True
Suite Setup    New Browser    browser=${BROWSER}    headless=${HEADLESS}
Test Setup    New Context    viewport={'width': 1280, 'height': 720}
Test Teardown    Close Context
Suite Teardown    Close Browser    ALL

*** Variables ***
${BROWSER}    chromium
${HEADLESS}    True

*** Test Cases ***
Login with valid credentials
    New Page    https://the-internet.herokuapp.com/login
    Fill Text    id=user    tomsmith
    Fill Text    id=pass    SuperSecretPassword!
    Click    id=loginbutton
    Get Text    id=flash    *=    You logged into a secure area!
```

## Arguments

* `fix`: Specifies the mode of operation, set to "realtime" for real-time healing. Default is "realtime".
* `collect_locator_info`: Boolean flag to enable or disable the collection of locator information. Default is false.
* `use_locator_db`: Boolean flag to enable or disable the use of a locator database. Default is false.
* `use_llm_for_locator_proposals`: Boolean flag to enable or disable the use of a language model for generating locator proposals. Default is false.
* `heal_assertions`: Boolean flag to enable or disable the healing of assertions. Default is false. (not implemented yet)
* `locator_db_file`: Specifies the filename for the locator database. Default is "locator_db.json".

## Environment Variables

Example when running with Ollama LLM:

```bash
LLM_API_BASE=http://localhost:11434
LLM_TEXT_MODEL=ollama_chat/llama3.1
LLM_LOCATOR_MODEL=ollama_chat/llama3.1
LLM_VISION_MODEL=ollama_chat/llama3.2-vision
```

Example when using OpenAI:

```bash
LLM_API_KEY=YOUR_OPENAI_API_KEY
LLM_TEXT_MODEL=gpt-3.5-turbo
LLM_LOCATOR_MODEL=gpt-3.5-turbo
```

## Open the project in Gitpod.io
[![Open in Gitpod](https://gitpod.io/button/open-in-gitpod.svg)](https://gitpod.io/#https://github.com/manykarim/robotframework-heal)  
Try it out in  [Gitpod](https://gitpod.io/#https://github.com/manykarim/robotframework-heal)

## Short URL and QR Code

https://tinyurl.com/robot-heal

![QR Code](QR-Code.png)
