Healenium Self-Healing Framework

repository·master·Indexed 41 days ago

https://github.com/healenium/healenium

An open-source self-healing library for automated testing that uses machine learning to mitigate test failures caused by UI changes, such as modifications to element IDs or class names. It acts as a proxy between the test client and the Selenium server, supporting Java, Python, JavaScript, and C#. The system consists of a proxy, backend, and selector imitator, utilizing a PostgreSQL database for storing reference selectors and healing data.

Tokens
1.5K
Snippets
3
Records
8
Agent score
1%

What's inside Healenium

  1. What is Healenium?

    master

    Healenium is an open-source self-healing framework for automated testing that uses machine learning to improve test reliability. It automatically detects and heals test failures caused by UI changes, such as modifications to element IDs or class names.

    Healenium acts as a proxy between your test client and the Selenium server. It supports all languages compatible with Selenium, including Java, Python, JavaScript, and C#.

  2. How Healenium is structured

    master

    Healenium operates through a collection of interconnected services that manage the healing lifecycle and data storage:

    • postgres-db: A PostgreSQL database used to store reference selectors, healing data, and reports.
    • hlm-proxy: A proxy that intercepts client requests and forwards them to the Selenium server.
    • hlm-backend: A CRUD service for managing healing data.
    • selector imitator: A service that converts healed locators into a convenient format.
    • selenoid/selenium-grid: The underlying Selenium server used to execute tests.

    Healenium provides two primary integration approaches:

    1. Healenium-Proxy: Intercepts requests via a proxy.
    2. Healenium-Web: An alternative approach for different testing needs.

    For detailed mechanics, refer to the Healenium Approaches Overview and How Healenium Works.

  3. Configure the Healenium Backend service

    master

    The healenium service (image healenium/hlm-backend) is the core backend component. You can configure its database connection and operational behavior using the following environment variables:

    • SPRING_POSTGRES_DB: Name of the PostgreSQL database.
    • SPRING_POSTGRES_SCHEMA: PostgreSQL schema name.
    • SPRING_POSTGRES_USER: Database username.
    • SPRING_POSTGRES_PASSWORD: Database password.
    • SPRING_POSTGRES_DB_HOST: Hostname of the PostgreSQL database.
    • KEY_SELECTOR_URL: Set to false to disable key selector URL usage.
    • COLLECT_METRICS: Set to true to enable metrics collection.
    • FIND_ELEMENTS_AUTO_HEALING: Set to false to disable automatic element healing.
    • HLM_LOG_LEVEL: Sets the logging level (e.g., info, debug).
    healenium:
        image: healenium/hlm-backend:3.5.1
        environment:
          - SPRING_POSTGRES_DB=healenium
          - SPRING_POSTGRES_SCHEMA=healenium
          - SPRING_POSTGRES_USER=healenium_user
          - SPRING_POSTGRES_PASSWORD=YDk2nmNs4s9aCP6K
          - SPRING_POSTGRES_DB_HOST=postgres-db
          - KEY_SELECTOR_URL=false
          - COLLECT_METRICS=true
          - FIND_ELEMENTS_AUTO_HEALING=false
          - HLM_LOG_LEVEL=info
  4. Configure the HLM Proxy service

    master

    The hlm-proxy service (image healenium/hlm-proxy) acts as the intermediary for healing requests. Use these environment variables to control proxy behavior and service discovery:

    • RECOVERY_TRIES: Number of recovery attempts.
    • SCORE_CAP: The threshold score for healing (e.g., .6).
    • HEAL_ENABLED: Set to true to enable healing functionality.
    • SELENIUM_SERVER_URL: URL of the Selenium Hub.
    • HEALENIUM_SERVER_URL: URL of the Healenium backend.
    • HEALENIUM_SERVICE: URL of the Healenium service.
    • IMITATE_SERVICE: URL of the selector-imitator service.
    • HLM_LOG_LEVEL: Sets the logging level (e.g., debug).
    hlm-proxy:
        image: healenium/hlm-proxy:2.2.1
        environment:
          - RECOVERY_TRIES=1
          - SCORE_CAP=.6
          - HEAL_ENABLED=true
          - SELENIUM_SERVER_URL=http://selenium-hub:4444/wd/hub
          - HEALENIUM_SERVER_URL=http://localhost:7878
          - HEALENIUM_SERVICE=http://healenium:7878
          - IMITATE_SERVICE=http://selector-imitator:8000
          - HLM_LOG_LEVEL=debug
  5. Configure the PostgreSQL database for Healenium

    master

    The postgres-db service (image postgres:15.5-alpine) stores Healenium data. Configure it using:

    • POSTGRES_DB: Database name.
    • POSTGRES_USER: Database user.
    • POSTGRES_PASSWORD: Database password.

    Note: The service expects an initialization script at ./db/sql/init.sql mapped to /docker-entrypoint-initdb.d/init.sql.

    postgres-db:
        image: postgres:15.5-alpine
        environment:
          - POSTGRES_DB=healenium
          - POSTGRES_USER=healenium_user
          - POSTGRES_PASSWORD=YDk2nmNs4s9aCP6K