Google Gemini oracles for Robot Framework: text-only and multimodal (image) assertions.
Project description
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.
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file robotframework_gemini-0.3.5.tar.gz.
File metadata
- Download URL: robotframework_gemini-0.3.5.tar.gz
- Upload date:
- Size: 12.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a0b22be646766eba1dca2547fb88791ee46d3f517271100ce37bc66d54e4998c
|
|
| MD5 |
4be11fcbd8919dd3da134fda8175eb78
|
|
| BLAKE2b-256 |
1263fc0f5d0c44ee13d0ccd628d5e80691a495322f91ba5d7c13718b0055ef92
|
Provenance
The following attestation bundles were made for robotframework_gemini-0.3.5.tar.gz:
Publisher:
publish.yml on carlosnizolli/robotframework-gemini
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
robotframework_gemini-0.3.5.tar.gz -
Subject digest:
a0b22be646766eba1dca2547fb88791ee46d3f517271100ce37bc66d54e4998c - Sigstore transparency entry: 2215513338
- Sigstore integration time:
-
Permalink:
carlosnizolli/robotframework-gemini@05f0a220f5b2ae0632036a5ea33bc2da7c25380c -
Branch / Tag:
refs/tags/v0.3.5 - Owner: https://github.com/carlosnizolli
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@05f0a220f5b2ae0632036a5ea33bc2da7c25380c -
Trigger Event:
push
-
Statement type:
File details
Details for the file robotframework_gemini-0.3.5-py3-none-any.whl.
File metadata
- Download URL: robotframework_gemini-0.3.5-py3-none-any.whl
- Upload date:
- Size: 13.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
32454603cb708e212efb75607f18c9c8a283ad62ea7f7755ccc45da23c5341d4
|
|
| MD5 |
4775b85edf297e3f58ad49fd9069e9d0
|
|
| BLAKE2b-256 |
c1e60b37cf6301343833f06ac1b27608f0ccc61b42c6fb7edf9761e9e0cbb558
|
Provenance
The following attestation bundles were made for robotframework_gemini-0.3.5-py3-none-any.whl:
Publisher:
publish.yml on carlosnizolli/robotframework-gemini
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
robotframework_gemini-0.3.5-py3-none-any.whl -
Subject digest:
32454603cb708e212efb75607f18c9c8a283ad62ea7f7755ccc45da23c5341d4 - Sigstore transparency entry: 2215513360
- Sigstore integration time:
-
Permalink:
carlosnizolli/robotframework-gemini@05f0a220f5b2ae0632036a5ea33bc2da7c25380c -
Branch / Tag:
refs/tags/v0.3.5 - Owner: https://github.com/carlosnizolli
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@05f0a220f5b2ae0632036a5ea33bc2da7c25380c -
Trigger Event:
push
-
Statement type: