robotframework-gemini
English | Português (Brasil)
Robot Framework keyword library for Google Gemini oracles: text-only evaluation (API payloads, logs, JSON, etc.) or multimodal checks with an image (PNG file or a Robot Framework Browser screenshot).
- Multimodal: sends prompt text and the capture as a byte
Part(google-genai). - Recommended flow: two inputs — context (test framing) and evaluation (criterion or yes/no question).
- Browser optional: screenshot keywords need
Library Browser; text keywords work without a browser.
Installation
pip install robotframework-gemini
With Robot Framework Browser (Playwright) screenshot support:
pip install "robotframework-gemini[browser]"
python -m pip install robotframework
Local development:
python -m pip install -e ".[dev]"
Environment variables and Library import
| Variable / argument | Purpose |
|---|---|
GEMINI_API_KEY |
Gemini API key (required unless you pass api_key on the Library) |
GEMINI_MODEL |
Model id (e.g. gemini-flash-latest). If omitted, defaults to gemini-flash-latest. |
api_key (import) |
Overrides GEMINI_API_KEY at Library import |
model (import) |
Overrides GEMINI_MODEL at Library import |
By default the Library reads key and model from the environment. You can also pass them on import (useful in CI or suites that keep credentials in Robot variables):
*** Variables ***
${GEMINI_API_KEY} %{GEMINI_API_KEY}
${GEMINI_MODEL} gemini-flash-latest
*** Settings ***
Library GeminiLibrary api_key=${GEMINI_API_KEY} model=${GEMINI_MODEL}
Model only (key still comes from the environment):
Library GeminiLibrary model=gemini-flash-latest
Explicit package import (equivalent):
Library robotframework_gemini.library.GeminiLibrary api_key=${GEMINI_API_KEY} model=${GEMINI_MODEL}
Do not commit a literal API key; prefer
%{GEMINI_API_KEY}or CI secrets.
Keyword documentation
- English: docs/KEYWORDS.en.md
- Português: docs/KEYWORDS.pt-BR.md
Usage in Robot Framework
Note: examples use
Set VariableandCatenateinstead of theVARkeyword (Robot Framework 7.0+) to stay compatible with older Robot Framework versions.
Text only (no Browser)
*** Settings ***
Library GeminiLibrary
*** Keywords ***
Validate API response
${context}= Set Variable {"status": "ok", "items": 3}
${evaluation}= Set Variable Does the payload indicate success with items?
${model_response}= Gemini Evaluate Text ${context} ${evaluation}
Log ${model_response}
With a screenshot (Browser)
Import Browser before Gemini:
*** Settings ***
Library Browser
Library GeminiLibrary
*** Keywords ***
Check screen against a neutral criterion
${context}= Set Variable List filtered by Active status.
${evaluation}= Set Variable Do all visible items show Active status?
${model_response}= Gemini Evaluate With Screen ${context} ${evaluation}
Log ${model_response}
Recommended import (RobotCode, runtime, and PyPI):
Library GeminiLibrary api_key=${GEMINI_API_KEY} model=${GEMINI_MODEL}
Explicit package path (IDEs that prefer a full Python path):
Library robotframework_gemini.library.GeminiLibrary api_key=${GEMINI_API_KEY} model=${GEMINI_MODEL}
IDE and RobotCode
| Import form | Resolved by |
|---|---|
Library GeminiLibrary |
Top-level GeminiLibrary.py module (installed in the wheel or via src/ in a clone) |
Library robotframework_gemini.library.GeminiLibrary |
Standard Python package path |
In a repository clone, without installing:
robot.toml—python-path = ["src"]for RobotCode/LSP.vscode/settings.json—extraPathsfor Pylance/Cursor
With a local venv: pip install -e ".[dev]", then reload the IDE window after changes.
With an image file already saved:
Browser.Take Screenshot ${OUTPUT_DIR}/screen.png
${model_response}= Gemini Evaluate With Image File ${context} ${evaluation} ${OUTPUT_DIR}/screen.png
Verdict via prompt (first line) and 1–5 score:
${model_response}= Gemini Evaluate With Screen ${context} ${evaluation}
... extra_instructions=Reply with one word on the first line: Yes or No.
${verdict}= Get Line ${model_response} 0
Should Be Equal As Strings ${verdict} Yes
# Score 1–5: two steps (log the reason) or one-line shortcut
${model_response}= Gemini Evaluate Text Rating ${context} ${evaluation}
${rating_score}= Gemini Parse Rating ${model_response}
${rating_score}= Gemini Evaluate Text Rating Score ${context} ${evaluation}
Details for the three rating keywords: Scores 1–5 (EN).
See also examples/demo_template.robot.
Related projects
Part of a Robot Framework tooling set:
| Project | Description |
|---|---|
| robotframework-gemini_exemplos | Practical suites using this library |
| RobotToPGListener | Persist RF test results to PostgreSQL |
| docker-robotframework | Ubuntu image for RF + Browser CI/E2E |
| robotframework-docker-actions | GitHub Action to run tests with the Docker image in CI |
| RoboCop | Robocop as a GitHub Action |
Tests
pytest
Tests mock generate_content; there are no real API calls.
Security
See SECURITY.md for how to report vulnerabilities privately.
License
MIT.
Metadata
Release files for robotframework-gemini 0.3.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| robotframework_gemini-0.3.5.tar.gz | 12.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| robotframework_gemini-0.3.5-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 26.5 kB
Release files / robotframework_gemini-0.3.5.tar.gz
| Download URL | robotframework_gemini-0.3.5.tar.gz |
|---|---|
| Size | 12.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a0b22be646766eba1dca2547fb88791ee46d3f517271100ce37bc66d54e4998c
|
|
BLAKE2b-256 checksum How to use checksums |
1263fc0f5d0c44ee13d0ccd628d5e80691a495322f91ba5d7c13718b0055ef92
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 22, 2026.
Transparency logRelease files / robotframework_gemini-0.3.5-py3-none-any.whl
| Download URL | robotframework_gemini-0.3.5-py3-none-any.whl |
|---|---|
| Size | 13.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
32454603cb708e212efb75607f18c9c8a283ad62ea7f7755ccc45da23c5341d4
|
|
BLAKE2b-256 checksum How to use checksums |
c1e60b37cf6301343833f06ac1b27608f0ccc61b42c6fb7edf9761e9e0cbb558
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 22, 2026.
Transparency log