Skip to main content

AI-powered smart locator with retry functionality for Robot Framework using OpenAI

This project has been archived.

The maintainers of this project have marked this project as archived. No new releases are expected.

Project description

Robot Framework DomRetryLibrary

A Robot Framework library with AI-powered fallback for locator variables, enhancing test reliability by using OpenAI to dynamically generate element locators when primary locators fail.

Installation

Install the library using pip:

pip install robotframework-domretrylibrary

Usage

Import the library in your Robot Framework test file:

*** Settings ***
Library           SeleniumLibrary
Library           DomRetryLibrary    # Just use the direct class name

Define your locators and AI fallback descriptions:

*** Variables ***
${USERNAME_FIELD}      css=#non_existent_username_id
${AI_USERNAME_FIELD}   the username input field with placeholder 'Username'

Use the AI fallback in your tests:

*** Test Cases ***
Login Test
    Open Browser    https://example.com    chrome
    AI Fallback Locator    Input Text    USERNAME_FIELD    myusername
    Close Browser

API Key Setup

Store your OpenAI API key in a .env file in your project directory:

OPENAI_API_KEY=your_api_key_here

Or provide it when initializing the library:

*** Settings ***
Library    DomRetryLibrary    api_key=${OPENAI_API_KEY}

How It Works

  1. The library first attempts to use your primary locator
  2. If the primary locator fails, it uses OpenAI to generate a new locator based on your description
  3. The AI-generated locator is used as a fallback
  4. Successful fallbacks are logged for future reference

Library Parameters

When importing the library, you can set several parameters:

Library    DomRetryLibrary    
...    api_key=${OPENAI_API_KEY}    
...    model=gpt-4o    
...    locator_storage_file=my_locators.json
Parameter Default Description
api_key None OpenAI API key (falls back to environment variable)
model gpt-4o OpenAI model to use
locator_storage_file locator_comparison.json File to store successful AI locators

Keywords

The library provides the following keywords:

  • AI Fallback Locator - Add AI fallback to any locator-based keyword

License

MIT

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

robotframework_domretrylibrary-2.2.0.tar.gz (10.8 kB view details)

Uploaded Source

Built Distribution

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

robotframework_domretrylibrary-2.2.0-py3-none-any.whl (12.5 kB view details)

Uploaded Python 3

File details

Details for the file robotframework_domretrylibrary-2.2.0.tar.gz.

File metadata

File hashes

Hashes for robotframework_domretrylibrary-2.2.0.tar.gz
Algorithm Hash digest
SHA256 1a259a3583325d346f07b7cba9aa5c261f2bf604f520a478075955a4e2c7cb1f
MD5 58d9a838ad1a25881964d263830bbfaa
BLAKE2b-256 9627332f00ce07d917f4b87f751df4485b1d247624a5acdef61c0249c2f49eb5

See more details on using hashes here.

File details

Details for the file robotframework_domretrylibrary-2.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for robotframework_domretrylibrary-2.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e8cca95fb00f2d7fdab5a3b1acbe7db25a1aae53a76da215203730f81afc5a4b
MD5 efda552e5967f9c384f6636bc58203c3
BLAKE2b-256 d7eaa8b0599039cf71b33d2b3773433c16cff9f6957c4a9156cf596dcf508c8e

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