Skip to content

ianmenethil/robotframework

 
 

Repository files navigation

Natural Language to Robot Framework Test Generator

This project provides a web-based frontend to convert natural language queries into Robot Framework test cases using a Large Language Model (LLM) like Google's Gemini.

Project Structure

  • frontend/: Contains the HTML, CSS, and JavaScript for the user interface.
  • backend/: Contains the Python Flask server that handles requests, interacts with the LLM, and generates Robot Framework code.
  • backend/documentation/: Contains curated snippets of Robot Framework documentation used to provide context to the LLM.

Prerequisites

  • Node.js and npm (for the frontend)
  • Python 3.x and pip (for the backend)
  • Access to Google Gemini API and an API Key (for actual LLM integration - currently mocked)

Setup and Running

1. Backend Setup

  1. Navigate to the backend directory:

    cd backend
  2. Create and activate a Python virtual environment:

    python3 -m venv .venv
    source .venv/bin/activate  # On Windows use: .venv\Scripts\activate
  3. Install Python dependencies:

    pip install -r requirements.txt

    4. Set your Google API Key

    To enable interaction with the Google Gemini API, set your API key as an environment variable. This is now crucial for the backend to initialize correctly.

    Replace "YOUR_API_KEY" with your actual key:

    export GOOGLE_API_KEY="YOUR_API_KEY"
    # On Windows use: set GOOGLE_API_KEY="YOUR_API_KEY"

    Note: If this key is not set, the application will print a warning and API calls will likely fail.

  4. Run the Flask development server:

    python app.py

    The backend server will start on http://localhost:5000.

2. Frontend Setup

  1. In a new terminal window/tab, navigate to the frontend directory:
    cd frontend
    1. Install frontend development dependencies (including TypeScript):
      npm install
    2. Compile the TypeScript code:
      npm run build
      This will compile src/script.ts to dist/script.js, which is used by index.html.

3. Running the Application

1.  Ensure the backend Flask server is running (see Backend Setup, make sure `GOOGLE_API_KEY` is set).
2.  Ensure you have built the frontend TypeScript: navigate to the `frontend` directory and run `npm run build` if you haven't already or if you made changes to `src/script.ts`.
3.  Open the `frontend/index.html` file directly in your web browser.
4.  Type your natural language query into the text area (e.g., "Create a test that logs 'Hello World' to the console").
5.  Click the "Generate Test" button.
  1. The generated Robot Framework code (currently mocked) will appear in the output area.

How it Works (High-Level)

  1. The user enters a natural language query in the frontend.
  2. The frontend sends this query to the backend API (/generate-test).
  3. The backend Flask application receives the query.
  4. It constructs a prompt for the Gemini LLM, including the user's query and relevant snippets from the Robot Framework documentation (from backend/documentation/).
  5. (Currently Mocked) The backend would send this prompt to the Gemini API.
  6. (Currently Mocked) Gemini processes the prompt and returns generated Robot Framework code.
  7. The backend sends this generated code back to the frontend.
  8. The frontend displays the code to the user.

Future Enhancements

  • Integrate with a live Gemini API.
  • Improve Robot Framework documentation context (e.g., dynamic retrieval, vector database).
  • More sophisticated error handling and user feedback.
  • Add options for different Robot Framework output formats or settings.

About

Generic automation framework for acceptance testing and RPA

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • Python 68.7%
  • RobotFramework 17.2%
  • TypeScript 8.4%
  • HTML 3.0%
  • JavaScript 2.0%
  • CSS 0.7%