robotframework-gemini 0.2.0__tar.gz → 0.3.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- robotframework_gemini-0.3.1/PKG-INFO +227 -0
- robotframework_gemini-0.3.1/README.md +193 -0
- {robotframework_gemini-0.2.0 → robotframework_gemini-0.3.1}/pyproject.toml +12 -2
- robotframework_gemini-0.3.1/src/BrowserGeminiLibrary.py +10 -0
- robotframework_gemini-0.3.1/src/GeminiLibrary.py +9 -0
- {robotframework_gemini-0.2.0 → robotframework_gemini-0.3.1}/src/robotframework_gemini/__init__.py +1 -1
- {robotframework_gemini-0.2.0 → robotframework_gemini-0.3.1}/src/robotframework_gemini/client.py +2 -2
- {robotframework_gemini-0.2.0 → robotframework_gemini-0.3.1}/src/robotframework_gemini/library.py +32 -3
- robotframework_gemini-0.3.1/src/robotframework_gemini/py.typed +0 -0
- robotframework_gemini-0.2.0/PKG-INFO +0 -171
- robotframework_gemini-0.2.0/README.md +0 -137
- {robotframework_gemini-0.2.0 → robotframework_gemini-0.3.1}/.gitignore +0 -0
- {robotframework_gemini-0.2.0 → robotframework_gemini-0.3.1}/LICENSE +0 -0
- {robotframework_gemini-0.2.0 → robotframework_gemini-0.3.1}/src/robotframework_gemini/browser_helpers.py +0 -0
- {robotframework_gemini-0.2.0 → robotframework_gemini-0.3.1}/src/robotframework_gemini/legacy_env.py +0 -0
- {robotframework_gemini-0.2.0 → robotframework_gemini-0.3.1}/src/robotframework_gemini/prompt_build.py +0 -0
- {robotframework_gemini-0.2.0 → robotframework_gemini-0.3.1}/src/robotframework_gemini/response_parse.py +0 -0
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: robotframework-gemini
|
|
3
|
+
Version: 0.3.1
|
|
4
|
+
Summary: Google Gemini oracles for Robot Framework: text-only and multimodal (image) assertions.
|
|
5
|
+
Project-URL: Homepage, https://github.com/carlosnizolli/robotframework-gemini
|
|
6
|
+
Project-URL: Documentation, https://github.com/carlosnizolli/robotframework-gemini#readme
|
|
7
|
+
Project-URL: Repository, https://github.com/carlosnizolli/robotframework-gemini
|
|
8
|
+
Project-URL: Issues, https://github.com/carlosnizolli/robotframework-gemini/issues
|
|
9
|
+
Project-URL: Changelog, https://github.com/carlosnizolli/robotframework-gemini/releases
|
|
10
|
+
Author: Carlos Nizolli
|
|
11
|
+
License-Expression: MIT
|
|
12
|
+
License-File: LICENSE
|
|
13
|
+
Keywords: Gemini,LLM,QA,Robot Framework,multimodal,testing
|
|
14
|
+
Classifier: Development Status :: 4 - Beta
|
|
15
|
+
Classifier: Framework :: Robot Framework
|
|
16
|
+
Classifier: Intended Audience :: Developers
|
|
17
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
18
|
+
Classifier: Operating System :: OS Independent
|
|
19
|
+
Classifier: Programming Language :: Python :: 3
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
23
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
24
|
+
Classifier: Topic :: Software Development :: Testing
|
|
25
|
+
Requires-Python: >=3.10
|
|
26
|
+
Requires-Dist: google-genai>=1.10.0
|
|
27
|
+
Provides-Extra: browser
|
|
28
|
+
Requires-Dist: robotframework-browser>=18.0.0; extra == 'browser'
|
|
29
|
+
Provides-Extra: dev
|
|
30
|
+
Requires-Dist: build>=1.0; extra == 'dev'
|
|
31
|
+
Requires-Dist: pytest>=8.0; extra == 'dev'
|
|
32
|
+
Requires-Dist: twine>=5.0; extra == 'dev'
|
|
33
|
+
Description-Content-Type: text/markdown
|
|
34
|
+
|
|
35
|
+
# robotframework-gemini
|
|
36
|
+
|
|
37
|
+
Biblioteca **Python** e **keywords do Robot Framework** para oráculos com **Google Gemini**: avaliação **só texto** (API, logs, JSON, etc.) ou **multimodal** com imagem (arquivo PNG ou captura do **Robot Framework Browser**).
|
|
38
|
+
|
|
39
|
+
- **Multimodal**: envia o texto do prompt e a captura como `Part` em bytes (`google-genai`).
|
|
40
|
+
- **Fluxo recomendado**: duas entradas — **contexto** (enquadramento do teste) e **avaliação** (critério ou pergunta objetiva).
|
|
41
|
+
- **Browser opcional**: keywords de screenshot exigem `Library Browser`; keywords de texto funcionam sem navegador.
|
|
42
|
+
|
|
43
|
+
## Instalação
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
pip install robotframework-gemini
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
Com suporte a captura via Robot Framework Browser (Playwright):
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
pip install "robotframework-gemini[browser]"
|
|
53
|
+
python -m pip install robotframework
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Desenvolvimento local:
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
python -m pip install -e ".[dev]"
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## Variáveis de ambiente e importação da Library
|
|
63
|
+
|
|
64
|
+
| Variável / argumento | Função |
|
|
65
|
+
|----------------------|--------|
|
|
66
|
+
| `GEMINI_API_KEY` | Chave da API Gemini (obrigatória se não passar `api_key` na Library) |
|
|
67
|
+
| `GEMINI_MODEL` | Modelo (ex.: `gemini-2.5-flash`). Se omitido, usa `gemini-2.5-flash`. |
|
|
68
|
+
| `api_key` (import) | Sobrescreve `GEMINI_API_KEY` na importação da Library |
|
|
69
|
+
| `model` (import) | Sobrescreve `GEMINI_MODEL` na importação da Library |
|
|
70
|
+
|
|
71
|
+
Por padrão, a Library lê chave e modelo das variáveis de ambiente. Você também pode passá-los na importação (útil em CI ou suítes com credenciais em variáveis Robot):
|
|
72
|
+
|
|
73
|
+
```robot
|
|
74
|
+
*** Variables ***
|
|
75
|
+
${GEMINI_API_KEY} %{GEMINI_API_KEY}
|
|
76
|
+
${GEMINI_MODEL} gemini-2.5-flash
|
|
77
|
+
|
|
78
|
+
*** Settings ***
|
|
79
|
+
Library GeminiLibrary api_key=${GEMINI_API_KEY} model=${GEMINI_MODEL}
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
Só o modelo (chave continua vinda do ambiente):
|
|
83
|
+
|
|
84
|
+
```robot
|
|
85
|
+
Library GeminiLibrary model=gemini-2.5-flash
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
Import explícito (equivalente):
|
|
89
|
+
|
|
90
|
+
```robot
|
|
91
|
+
Library robotframework_gemini.library.GeminiLibrary api_key=${GEMINI_API_KEY} model=${GEMINI_MODEL}
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
> Evite commitar a chave literal no repositório; prefira `%{GEMINI_API_KEY}` ou secrets do CI.
|
|
95
|
+
|
|
96
|
+
## Uso em Python (`GeminiOrchestrator`)
|
|
97
|
+
|
|
98
|
+
```python
|
|
99
|
+
from pathlib import Path
|
|
100
|
+
from robotframework_gemini import GeminiOrchestrator
|
|
101
|
+
|
|
102
|
+
orchestrator = GeminiOrchestrator()
|
|
103
|
+
# ou explicitamente:
|
|
104
|
+
# orchestrator = GeminiOrchestrator(api_key="...", model="gemini-2.5-flash")
|
|
105
|
+
context = "Web dashboard with the 'Active' category filter applied."
|
|
106
|
+
evaluation = "Do the visible list items match the selected category?"
|
|
107
|
+
model_response = orchestrator.evaluate_with_image(context, evaluation, Path("screen.png"))
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
Para formato de saída restrito (ex.: Yes/No), use `extra_instructions`:
|
|
111
|
+
|
|
112
|
+
```python
|
|
113
|
+
model_response = orchestrator.evaluate_with_text(
|
|
114
|
+
context,
|
|
115
|
+
evaluation,
|
|
116
|
+
extra_instructions="Reply with one word only: Yes or No.",
|
|
117
|
+
)
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
## Uso no Robot Framework
|
|
121
|
+
|
|
122
|
+
> **Nota:** os exemplos usam `Set Variable` e `Catenate` em vez da keyword `VAR` (Robot Framework 7.0+) para manter retrocompatibilidade com versões anteriores do Robot Framework.
|
|
123
|
+
|
|
124
|
+
### Só texto (sem Browser)
|
|
125
|
+
|
|
126
|
+
```robot
|
|
127
|
+
*** Settings ***
|
|
128
|
+
Library GeminiLibrary
|
|
129
|
+
|
|
130
|
+
*** Keywords ***
|
|
131
|
+
Validar resposta da API
|
|
132
|
+
${context}= Set Variable {"status": "ok", "items": 3}
|
|
133
|
+
${evaluation}= Set Variable O payload indica sucesso com itens?
|
|
134
|
+
${model_response}= Gemini Evaluate Text ${context} ${evaluation}
|
|
135
|
+
Log ${model_response}
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
### Com captura de tela (Browser)
|
|
139
|
+
|
|
140
|
+
Declare a biblioteca **Browser** antes de **Gemini**:
|
|
141
|
+
|
|
142
|
+
```robot
|
|
143
|
+
*** Settings ***
|
|
144
|
+
Library Browser
|
|
145
|
+
Library GeminiLibrary
|
|
146
|
+
|
|
147
|
+
*** Keywords ***
|
|
148
|
+
Checar tela por critério neutro
|
|
149
|
+
${context}= Set Variable Lista filtrada por status Ativo.
|
|
150
|
+
${evaluation}= Set Variable Todos os itens visíveis mostram status Ativo?
|
|
151
|
+
${model_response}= Gemini Evaluate With Screen ${context} ${evaluation}
|
|
152
|
+
Log ${model_response}
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
Import recomendado (RobotCode, runtime e PyPI):
|
|
156
|
+
|
|
157
|
+
```robot
|
|
158
|
+
Library GeminiLibrary api_key=${GEMINI_API_KEY} model=${GEMINI_MODEL}
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
Import explícito do pacote (Python / IDEs que preferem o caminho completo):
|
|
162
|
+
|
|
163
|
+
```robot
|
|
164
|
+
Library robotframework_gemini.library.GeminiLibrary api_key=${GEMINI_API_KEY} model=${GEMINI_MODEL}
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
### IDE e RobotCode
|
|
168
|
+
|
|
169
|
+
| Forma de import | Quem resolve |
|
|
170
|
+
|-----------------|--------------|
|
|
171
|
+
| `Library GeminiLibrary` | Módulo top-level `GeminiLibrary.py` (instalado no wheel ou via `src/` no clone) |
|
|
172
|
+
| `Library robotframework_gemini.library.GeminiLibrary` | Pacote Python padrão |
|
|
173
|
+
|
|
174
|
+
No **clone do repositório**, sem instalar:
|
|
175
|
+
|
|
176
|
+
- [`robot.toml`](robot.toml) — `python-path = ["src"]` para RobotCode/LSP
|
|
177
|
+
- [`.vscode/settings.json`](.vscode/settings.json) — `extraPaths` para Pylance/Cursor
|
|
178
|
+
|
|
179
|
+
Com venv local: `pip install -e ".[dev]"` e recarregue a janela do IDE após mudanças.
|
|
180
|
+
|
|
181
|
+
Com arquivo já salvo:
|
|
182
|
+
|
|
183
|
+
```robot
|
|
184
|
+
Browser.Take Screenshot ${OUTPUT_DIR}/tela.png
|
|
185
|
+
${model_response}= Gemini Evaluate With Image File ${context} ${evaluation} ${OUTPUT_DIR}/tela.png
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
Veredito via prompt (primeira linha) e nota 1–5:
|
|
189
|
+
|
|
190
|
+
```robot
|
|
191
|
+
${model_response}= Gemini Evaluate With Screen ${context} ${evaluation}
|
|
192
|
+
... extra_instructions=Responda com uma palavra na primeira linha: Sim ou Não.
|
|
193
|
+
${verdict}= Get Line ${model_response} 0
|
|
194
|
+
Should Be Equal As Strings ${verdict} Sim
|
|
195
|
+
|
|
196
|
+
# Nota 1–5: duas etapas (log da justificativa) ou atalho em uma linha
|
|
197
|
+
${model_response}= Gemini Evaluate Text Rating ${context} ${evaluation}
|
|
198
|
+
${rating_score}= Gemini Parse Rating ${model_response}
|
|
199
|
+
|
|
200
|
+
${rating_score}= Gemini Evaluate Text Rating Score ${context} ${evaluation}
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
Detalhes das três keywords de nota: [`docs/KEYWORDS.pt-BR.md#notas-15-três-keywords-quando-usar`](docs/KEYWORDS.pt-BR.md#notas-15-três-keywords-quando-usar).
|
|
204
|
+
|
|
205
|
+
Consulte também [`examples/demo_template.robot`](examples/demo_template.robot).
|
|
206
|
+
|
|
207
|
+
## Documentação de Keywords
|
|
208
|
+
|
|
209
|
+
- Português: [`docs/KEYWORDS.pt-BR.md`](docs/KEYWORDS.pt-BR.md)
|
|
210
|
+
- English: [`docs/KEYWORDS.en.md`](docs/KEYWORDS.en.md)
|
|
211
|
+
|
|
212
|
+
## Compatibilidade
|
|
213
|
+
|
|
214
|
+
- `BrowserGeminiLibrary` permanece como alias de `GeminiLibrary` para suítes existentes.
|
|
215
|
+
- Variáveis legadas (`LLM_API_KEY`, `LLM_API_KEY_LIA`, `LLM_LIA_MODEL`) são mapeadas para `GEMINI_*` ao importar o pacote.
|
|
216
|
+
|
|
217
|
+
## Testes
|
|
218
|
+
|
|
219
|
+
```bash
|
|
220
|
+
pytest
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
Os testes usam mocks de `generate_content`; não há chamadas reais à API.
|
|
224
|
+
|
|
225
|
+
## Licença
|
|
226
|
+
|
|
227
|
+
MIT.
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
# robotframework-gemini
|
|
2
|
+
|
|
3
|
+
Biblioteca **Python** e **keywords do Robot Framework** para oráculos com **Google Gemini**: avaliação **só texto** (API, logs, JSON, etc.) ou **multimodal** com imagem (arquivo PNG ou captura do **Robot Framework Browser**).
|
|
4
|
+
|
|
5
|
+
- **Multimodal**: envia o texto do prompt e a captura como `Part` em bytes (`google-genai`).
|
|
6
|
+
- **Fluxo recomendado**: duas entradas — **contexto** (enquadramento do teste) e **avaliação** (critério ou pergunta objetiva).
|
|
7
|
+
- **Browser opcional**: keywords de screenshot exigem `Library Browser`; keywords de texto funcionam sem navegador.
|
|
8
|
+
|
|
9
|
+
## Instalação
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
pip install robotframework-gemini
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
Com suporte a captura via Robot Framework Browser (Playwright):
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
pip install "robotframework-gemini[browser]"
|
|
19
|
+
python -m pip install robotframework
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
Desenvolvimento local:
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
python -m pip install -e ".[dev]"
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Variáveis de ambiente e importação da Library
|
|
29
|
+
|
|
30
|
+
| Variável / argumento | Função |
|
|
31
|
+
|----------------------|--------|
|
|
32
|
+
| `GEMINI_API_KEY` | Chave da API Gemini (obrigatória se não passar `api_key` na Library) |
|
|
33
|
+
| `GEMINI_MODEL` | Modelo (ex.: `gemini-2.5-flash`). Se omitido, usa `gemini-2.5-flash`. |
|
|
34
|
+
| `api_key` (import) | Sobrescreve `GEMINI_API_KEY` na importação da Library |
|
|
35
|
+
| `model` (import) | Sobrescreve `GEMINI_MODEL` na importação da Library |
|
|
36
|
+
|
|
37
|
+
Por padrão, a Library lê chave e modelo das variáveis de ambiente. Você também pode passá-los na importação (útil em CI ou suítes com credenciais em variáveis Robot):
|
|
38
|
+
|
|
39
|
+
```robot
|
|
40
|
+
*** Variables ***
|
|
41
|
+
${GEMINI_API_KEY} %{GEMINI_API_KEY}
|
|
42
|
+
${GEMINI_MODEL} gemini-2.5-flash
|
|
43
|
+
|
|
44
|
+
*** Settings ***
|
|
45
|
+
Library GeminiLibrary api_key=${GEMINI_API_KEY} model=${GEMINI_MODEL}
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
Só o modelo (chave continua vinda do ambiente):
|
|
49
|
+
|
|
50
|
+
```robot
|
|
51
|
+
Library GeminiLibrary model=gemini-2.5-flash
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
Import explícito (equivalente):
|
|
55
|
+
|
|
56
|
+
```robot
|
|
57
|
+
Library robotframework_gemini.library.GeminiLibrary api_key=${GEMINI_API_KEY} model=${GEMINI_MODEL}
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
> Evite commitar a chave literal no repositório; prefira `%{GEMINI_API_KEY}` ou secrets do CI.
|
|
61
|
+
|
|
62
|
+
## Uso em Python (`GeminiOrchestrator`)
|
|
63
|
+
|
|
64
|
+
```python
|
|
65
|
+
from pathlib import Path
|
|
66
|
+
from robotframework_gemini import GeminiOrchestrator
|
|
67
|
+
|
|
68
|
+
orchestrator = GeminiOrchestrator()
|
|
69
|
+
# ou explicitamente:
|
|
70
|
+
# orchestrator = GeminiOrchestrator(api_key="...", model="gemini-2.5-flash")
|
|
71
|
+
context = "Web dashboard with the 'Active' category filter applied."
|
|
72
|
+
evaluation = "Do the visible list items match the selected category?"
|
|
73
|
+
model_response = orchestrator.evaluate_with_image(context, evaluation, Path("screen.png"))
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
Para formato de saída restrito (ex.: Yes/No), use `extra_instructions`:
|
|
77
|
+
|
|
78
|
+
```python
|
|
79
|
+
model_response = orchestrator.evaluate_with_text(
|
|
80
|
+
context,
|
|
81
|
+
evaluation,
|
|
82
|
+
extra_instructions="Reply with one word only: Yes or No.",
|
|
83
|
+
)
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
## Uso no Robot Framework
|
|
87
|
+
|
|
88
|
+
> **Nota:** os exemplos usam `Set Variable` e `Catenate` em vez da keyword `VAR` (Robot Framework 7.0+) para manter retrocompatibilidade com versões anteriores do Robot Framework.
|
|
89
|
+
|
|
90
|
+
### Só texto (sem Browser)
|
|
91
|
+
|
|
92
|
+
```robot
|
|
93
|
+
*** Settings ***
|
|
94
|
+
Library GeminiLibrary
|
|
95
|
+
|
|
96
|
+
*** Keywords ***
|
|
97
|
+
Validar resposta da API
|
|
98
|
+
${context}= Set Variable {"status": "ok", "items": 3}
|
|
99
|
+
${evaluation}= Set Variable O payload indica sucesso com itens?
|
|
100
|
+
${model_response}= Gemini Evaluate Text ${context} ${evaluation}
|
|
101
|
+
Log ${model_response}
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
### Com captura de tela (Browser)
|
|
105
|
+
|
|
106
|
+
Declare a biblioteca **Browser** antes de **Gemini**:
|
|
107
|
+
|
|
108
|
+
```robot
|
|
109
|
+
*** Settings ***
|
|
110
|
+
Library Browser
|
|
111
|
+
Library GeminiLibrary
|
|
112
|
+
|
|
113
|
+
*** Keywords ***
|
|
114
|
+
Checar tela por critério neutro
|
|
115
|
+
${context}= Set Variable Lista filtrada por status Ativo.
|
|
116
|
+
${evaluation}= Set Variable Todos os itens visíveis mostram status Ativo?
|
|
117
|
+
${model_response}= Gemini Evaluate With Screen ${context} ${evaluation}
|
|
118
|
+
Log ${model_response}
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
Import recomendado (RobotCode, runtime e PyPI):
|
|
122
|
+
|
|
123
|
+
```robot
|
|
124
|
+
Library GeminiLibrary api_key=${GEMINI_API_KEY} model=${GEMINI_MODEL}
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
Import explícito do pacote (Python / IDEs que preferem o caminho completo):
|
|
128
|
+
|
|
129
|
+
```robot
|
|
130
|
+
Library robotframework_gemini.library.GeminiLibrary api_key=${GEMINI_API_KEY} model=${GEMINI_MODEL}
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
### IDE e RobotCode
|
|
134
|
+
|
|
135
|
+
| Forma de import | Quem resolve |
|
|
136
|
+
|-----------------|--------------|
|
|
137
|
+
| `Library GeminiLibrary` | Módulo top-level `GeminiLibrary.py` (instalado no wheel ou via `src/` no clone) |
|
|
138
|
+
| `Library robotframework_gemini.library.GeminiLibrary` | Pacote Python padrão |
|
|
139
|
+
|
|
140
|
+
No **clone do repositório**, sem instalar:
|
|
141
|
+
|
|
142
|
+
- [`robot.toml`](robot.toml) — `python-path = ["src"]` para RobotCode/LSP
|
|
143
|
+
- [`.vscode/settings.json`](.vscode/settings.json) — `extraPaths` para Pylance/Cursor
|
|
144
|
+
|
|
145
|
+
Com venv local: `pip install -e ".[dev]"` e recarregue a janela do IDE após mudanças.
|
|
146
|
+
|
|
147
|
+
Com arquivo já salvo:
|
|
148
|
+
|
|
149
|
+
```robot
|
|
150
|
+
Browser.Take Screenshot ${OUTPUT_DIR}/tela.png
|
|
151
|
+
${model_response}= Gemini Evaluate With Image File ${context} ${evaluation} ${OUTPUT_DIR}/tela.png
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
Veredito via prompt (primeira linha) e nota 1–5:
|
|
155
|
+
|
|
156
|
+
```robot
|
|
157
|
+
${model_response}= Gemini Evaluate With Screen ${context} ${evaluation}
|
|
158
|
+
... extra_instructions=Responda com uma palavra na primeira linha: Sim ou Não.
|
|
159
|
+
${verdict}= Get Line ${model_response} 0
|
|
160
|
+
Should Be Equal As Strings ${verdict} Sim
|
|
161
|
+
|
|
162
|
+
# Nota 1–5: duas etapas (log da justificativa) ou atalho em uma linha
|
|
163
|
+
${model_response}= Gemini Evaluate Text Rating ${context} ${evaluation}
|
|
164
|
+
${rating_score}= Gemini Parse Rating ${model_response}
|
|
165
|
+
|
|
166
|
+
${rating_score}= Gemini Evaluate Text Rating Score ${context} ${evaluation}
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
Detalhes das três keywords de nota: [`docs/KEYWORDS.pt-BR.md#notas-15-três-keywords-quando-usar`](docs/KEYWORDS.pt-BR.md#notas-15-três-keywords-quando-usar).
|
|
170
|
+
|
|
171
|
+
Consulte também [`examples/demo_template.robot`](examples/demo_template.robot).
|
|
172
|
+
|
|
173
|
+
## Documentação de Keywords
|
|
174
|
+
|
|
175
|
+
- Português: [`docs/KEYWORDS.pt-BR.md`](docs/KEYWORDS.pt-BR.md)
|
|
176
|
+
- English: [`docs/KEYWORDS.en.md`](docs/KEYWORDS.en.md)
|
|
177
|
+
|
|
178
|
+
## Compatibilidade
|
|
179
|
+
|
|
180
|
+
- `BrowserGeminiLibrary` permanece como alias de `GeminiLibrary` para suítes existentes.
|
|
181
|
+
- Variáveis legadas (`LLM_API_KEY`, `LLM_API_KEY_LIA`, `LLM_LIA_MODEL`) são mapeadas para `GEMINI_*` ao importar o pacote.
|
|
182
|
+
|
|
183
|
+
## Testes
|
|
184
|
+
|
|
185
|
+
```bash
|
|
186
|
+
pytest
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
Os testes usam mocks de `generate_content`; não há chamadas reais à API.
|
|
190
|
+
|
|
191
|
+
## Licença
|
|
192
|
+
|
|
193
|
+
MIT.
|
|
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "robotframework-gemini"
|
|
7
|
-
version = "0.
|
|
7
|
+
version = "0.3.1"
|
|
8
8
|
description = "Google Gemini oracles for Robot Framework: text-only and multimodal (image) assertions."
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.10"
|
|
@@ -47,14 +47,24 @@ dev = [
|
|
|
47
47
|
]
|
|
48
48
|
|
|
49
49
|
[project.entry-points."robotframework.libraries"]
|
|
50
|
-
GeminiLibrary = "
|
|
50
|
+
GeminiLibrary = "GeminiLibrary:GeminiLibrary"
|
|
51
|
+
BrowserGeminiLibrary = "BrowserGeminiLibrary:BrowserGeminiLibrary"
|
|
51
52
|
|
|
52
53
|
[tool.hatch.build.targets.wheel]
|
|
53
54
|
packages = ["src/robotframework_gemini"]
|
|
54
55
|
|
|
56
|
+
[tool.hatch.build.targets.wheel.force-include]
|
|
57
|
+
"src/GeminiLibrary.py" = "GeminiLibrary.py"
|
|
58
|
+
"src/BrowserGeminiLibrary.py" = "BrowserGeminiLibrary.py"
|
|
59
|
+
|
|
60
|
+
[tool.hatch.build.targets.editable]
|
|
61
|
+
dev-mode-dirs = ["src"]
|
|
62
|
+
|
|
55
63
|
[tool.hatch.build.targets.sdist]
|
|
56
64
|
include = [
|
|
57
65
|
"src/robotframework_gemini",
|
|
66
|
+
"src/GeminiLibrary.py",
|
|
67
|
+
"src/BrowserGeminiLibrary.py",
|
|
58
68
|
"LICENSE",
|
|
59
69
|
"README.md",
|
|
60
70
|
]
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"""Backward-compatible shim for ``Library BrowserGeminiLibrary``."""
|
|
2
|
+
|
|
3
|
+
from robotframework_gemini.library import GeminiLibrary
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class BrowserGeminiLibrary(GeminiLibrary):
|
|
7
|
+
"""Alias of :class:`robotframework_gemini.library.GeminiLibrary`."""
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
__all__ = ["BrowserGeminiLibrary"]
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"""Top-level shim so ``Library GeminiLibrary`` resolves via ``import GeminiLibrary``.
|
|
2
|
+
|
|
3
|
+
Robot Framework entry points work at runtime; RobotCode and other tools often
|
|
4
|
+
import the library name as a Python module first.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from robotframework_gemini.library import GeminiLibrary
|
|
8
|
+
|
|
9
|
+
__all__ = ["GeminiLibrary"]
|
{robotframework_gemini-0.2.0 → robotframework_gemini-0.3.1}/src/robotframework_gemini/client.py
RENAMED
|
@@ -33,7 +33,7 @@ class GeminiOrchestrator:
|
|
|
33
33
|
|
|
34
34
|
Environment:
|
|
35
35
|
- GEMINI_API_KEY for the API key (unless ``api_key`` is passed explicitly)
|
|
36
|
-
- GEMINI_MODEL for model id (e.g. gemini-2.
|
|
36
|
+
- GEMINI_MODEL for model id (e.g. gemini-2.5-flash); defaults to gemini-2.5-flash
|
|
37
37
|
"""
|
|
38
38
|
|
|
39
39
|
def __init__(
|
|
@@ -47,7 +47,7 @@ class GeminiOrchestrator:
|
|
|
47
47
|
raise ValueError(
|
|
48
48
|
"Missing API key: set GEMINI_API_KEY (or pass api_key=...)"
|
|
49
49
|
)
|
|
50
|
-
self.model = model or os.environ.get("GEMINI_MODEL") or "gemini-2.
|
|
50
|
+
self.model = model or os.environ.get("GEMINI_MODEL") or "gemini-2.5-flash"
|
|
51
51
|
self._client = genai.Client(api_key=key)
|
|
52
52
|
|
|
53
53
|
def generate_from_text(self, prompt: str) -> str:
|
{robotframework_gemini-0.2.0 → robotframework_gemini-0.3.1}/src/robotframework_gemini/library.py
RENAMED
|
@@ -33,7 +33,12 @@ ensure_gemini_env_from_legacy()
|
|
|
33
33
|
|
|
34
34
|
|
|
35
35
|
class GeminiLibrary:
|
|
36
|
-
"""Keywords for Gemini text oracles and optional Browser screenshot capture.
|
|
36
|
+
"""Keywords for Gemini text oracles and optional Browser screenshot capture.
|
|
37
|
+
|
|
38
|
+
Import arguments:
|
|
39
|
+
- ``api_key`` — Gemini API key (falls back to ``GEMINI_API_KEY`` when omitted)
|
|
40
|
+
- ``model`` — model id (falls back to ``GEMINI_MODEL``, then ``gemini-2.5-flash``)
|
|
41
|
+
"""
|
|
37
42
|
|
|
38
43
|
ROBOT_LIBRARY_SCOPE = "GLOBAL"
|
|
39
44
|
|
|
@@ -162,7 +167,8 @@ class GeminiLibrary:
|
|
|
162
167
|
|
|
163
168
|
``context`` — any test evidence (API body, logs, UI text, file excerpt, etc.).
|
|
164
169
|
``evaluation`` — criterion to score (how well the evidence meets the test intent).
|
|
165
|
-
Use ``Gemini Parse Rating`` to extract
|
|
170
|
+
Returns raw model text (``SCORE:`` + ``REASON:``). Use ``Gemini Parse Rating`` to extract
|
|
171
|
+
the integer, or ``Gemini Evaluate Text Rating Score`` for a one-step score only.
|
|
166
172
|
``extra_instructions`` is appended after the built-in rubric.
|
|
167
173
|
"""
|
|
168
174
|
return self._get_orchestrator().evaluate_with_text_rating(
|
|
@@ -173,9 +179,32 @@ class GeminiLibrary:
|
|
|
173
179
|
|
|
174
180
|
@keyword("Gemini Parse Rating")
|
|
175
181
|
def gemini_parse_rating(self, raw_response: str) -> str:
|
|
176
|
-
"""Extract score 1–5 from a judge response; returns raw text if parsing fails.
|
|
182
|
+
"""Extract score 1–5 from a judge response; returns raw text if parsing fails.
|
|
183
|
+
|
|
184
|
+
Local parsing only (no API call). Works on output from ``Gemini Evaluate Text Rating``
|
|
185
|
+
or any text that follows ``SCORE:``/``NOTA:`` format.
|
|
186
|
+
"""
|
|
177
187
|
return GeminiOrchestrator.parse_rating(raw_response)
|
|
178
188
|
|
|
189
|
+
@keyword("Gemini Evaluate Text Rating Score")
|
|
190
|
+
def gemini_evaluate_text_rating_score(
|
|
191
|
+
self,
|
|
192
|
+
context: str,
|
|
193
|
+
evaluation: str,
|
|
194
|
+
extra_instructions: str | None = None,
|
|
195
|
+
) -> str:
|
|
196
|
+
"""Convenience: ``Gemini Evaluate Text Rating`` + ``Gemini Parse Rating`` in one call.
|
|
197
|
+
|
|
198
|
+
Returns only the integer score ``1``–``5`` as text. Prefer the two-step flow when you
|
|
199
|
+
need to log or assert on the full ``SCORE``/``REASON`` response from the model.
|
|
200
|
+
"""
|
|
201
|
+
model_response = self.gemini_evaluate_text_rating(
|
|
202
|
+
context,
|
|
203
|
+
evaluation,
|
|
204
|
+
extra_instructions=extra_instructions,
|
|
205
|
+
)
|
|
206
|
+
return self.gemini_parse_rating(model_response)
|
|
207
|
+
|
|
179
208
|
@keyword("Gemini Generate From Prompt")
|
|
180
209
|
def gemini_generate_from_prompt(self, prompt: str) -> str:
|
|
181
210
|
"""Send a single text prompt and return the model reply (no context/evaluation template)."""
|
|
File without changes
|
|
@@ -1,171 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.4
|
|
2
|
-
Name: robotframework-gemini
|
|
3
|
-
Version: 0.2.0
|
|
4
|
-
Summary: Google Gemini oracles for Robot Framework: text-only and multimodal (image) assertions.
|
|
5
|
-
Project-URL: Homepage, https://github.com/carlosnizolli/robotframework-gemini
|
|
6
|
-
Project-URL: Documentation, https://github.com/carlosnizolli/robotframework-gemini#readme
|
|
7
|
-
Project-URL: Repository, https://github.com/carlosnizolli/robotframework-gemini
|
|
8
|
-
Project-URL: Issues, https://github.com/carlosnizolli/robotframework-gemini/issues
|
|
9
|
-
Project-URL: Changelog, https://github.com/carlosnizolli/robotframework-gemini/releases
|
|
10
|
-
Author: Carlos Nizolli
|
|
11
|
-
License-Expression: MIT
|
|
12
|
-
License-File: LICENSE
|
|
13
|
-
Keywords: Gemini,LLM,QA,Robot Framework,multimodal,testing
|
|
14
|
-
Classifier: Development Status :: 4 - Beta
|
|
15
|
-
Classifier: Framework :: Robot Framework
|
|
16
|
-
Classifier: Intended Audience :: Developers
|
|
17
|
-
Classifier: License :: OSI Approved :: MIT License
|
|
18
|
-
Classifier: Operating System :: OS Independent
|
|
19
|
-
Classifier: Programming Language :: Python :: 3
|
|
20
|
-
Classifier: Programming Language :: Python :: 3.10
|
|
21
|
-
Classifier: Programming Language :: Python :: 3.11
|
|
22
|
-
Classifier: Programming Language :: Python :: 3.12
|
|
23
|
-
Classifier: Programming Language :: Python :: 3.13
|
|
24
|
-
Classifier: Topic :: Software Development :: Testing
|
|
25
|
-
Requires-Python: >=3.10
|
|
26
|
-
Requires-Dist: google-genai>=1.10.0
|
|
27
|
-
Provides-Extra: browser
|
|
28
|
-
Requires-Dist: robotframework-browser>=18.0.0; extra == 'browser'
|
|
29
|
-
Provides-Extra: dev
|
|
30
|
-
Requires-Dist: build>=1.0; extra == 'dev'
|
|
31
|
-
Requires-Dist: pytest>=8.0; extra == 'dev'
|
|
32
|
-
Requires-Dist: twine>=5.0; extra == 'dev'
|
|
33
|
-
Description-Content-Type: text/markdown
|
|
34
|
-
|
|
35
|
-
# robotframework-gemini
|
|
36
|
-
|
|
37
|
-
Biblioteca **Python** e **keywords do Robot Framework** para oráculos com **Google Gemini**: avaliação **só texto** (API, logs, JSON, etc.) ou **multimodal** com imagem (arquivo PNG ou captura do **Robot Framework Browser**).
|
|
38
|
-
|
|
39
|
-
- **Multimodal**: envia o texto do prompt e a captura como `Part` em bytes (`google-genai`).
|
|
40
|
-
- **Fluxo recomendado**: duas entradas — **contexto** (enquadramento do teste) e **avaliação** (critério ou pergunta objetiva).
|
|
41
|
-
- **Browser opcional**: keywords de screenshot exigem `Library Browser`; keywords de texto funcionam sem navegador.
|
|
42
|
-
|
|
43
|
-
## Instalação
|
|
44
|
-
|
|
45
|
-
```bash
|
|
46
|
-
pip install robotframework-gemini
|
|
47
|
-
```
|
|
48
|
-
|
|
49
|
-
Com suporte a captura via Robot Framework Browser (Playwright):
|
|
50
|
-
|
|
51
|
-
```bash
|
|
52
|
-
pip install "robotframework-gemini[browser]"
|
|
53
|
-
python -m pip install robotframework
|
|
54
|
-
```
|
|
55
|
-
|
|
56
|
-
Desenvolvimento local:
|
|
57
|
-
|
|
58
|
-
```bash
|
|
59
|
-
python -m pip install -e ".[dev]"
|
|
60
|
-
```
|
|
61
|
-
|
|
62
|
-
## Variáveis de ambiente
|
|
63
|
-
|
|
64
|
-
| Variável | Função |
|
|
65
|
-
|-------------------|---------------------------------------------|
|
|
66
|
-
| `GEMINI_API_KEY` | Chave da API Gemini (obrigatória se não passar `api_key` na Library) |
|
|
67
|
-
| `GEMINI_MODEL` | Modelo (ex.: `gemini-2.0-flash`). Se omitido, usa `gemini-2.0-flash`. |
|
|
68
|
-
|
|
69
|
-
## Uso em Python (`GeminiOrchestrator`)
|
|
70
|
-
|
|
71
|
-
```python
|
|
72
|
-
from pathlib import Path
|
|
73
|
-
from robotframework_gemini import GeminiOrchestrator
|
|
74
|
-
|
|
75
|
-
orc = GeminiOrchestrator()
|
|
76
|
-
ctx = "Web dashboard with the 'Active' category filter applied."
|
|
77
|
-
crit = "Do the visible list items match the selected category?"
|
|
78
|
-
raw = orc.evaluate_with_image(ctx, crit, Path("screen.png"))
|
|
79
|
-
```
|
|
80
|
-
|
|
81
|
-
Para formato de saída restrito (ex.: Yes/No), use `extra_instructions`:
|
|
82
|
-
|
|
83
|
-
```python
|
|
84
|
-
raw = orc.evaluate_with_text(
|
|
85
|
-
ctx,
|
|
86
|
-
crit,
|
|
87
|
-
extra_instructions="Reply with one word only: Yes or No.",
|
|
88
|
-
)
|
|
89
|
-
```
|
|
90
|
-
|
|
91
|
-
## Uso no Robot Framework
|
|
92
|
-
|
|
93
|
-
### Só texto (sem Browser)
|
|
94
|
-
|
|
95
|
-
```robot
|
|
96
|
-
*** Settings ***
|
|
97
|
-
Library GeminiLibrary
|
|
98
|
-
|
|
99
|
-
*** Keywords ***
|
|
100
|
-
Validar resposta da API
|
|
101
|
-
${ctx}= Set Variable {"status": "ok", "items": 3}
|
|
102
|
-
${crit}= Set Variable O payload indica sucesso com itens?
|
|
103
|
-
${raw}= Gemini Evaluate Text ${ctx} ${crit}
|
|
104
|
-
Log ${raw}
|
|
105
|
-
```
|
|
106
|
-
|
|
107
|
-
### Com captura de tela (Browser)
|
|
108
|
-
|
|
109
|
-
Declare a biblioteca **Browser** antes de **Gemini**:
|
|
110
|
-
|
|
111
|
-
```robot
|
|
112
|
-
*** Settings ***
|
|
113
|
-
Library Browser
|
|
114
|
-
Library GeminiLibrary
|
|
115
|
-
|
|
116
|
-
*** Keywords ***
|
|
117
|
-
Checar tela por critério neutro
|
|
118
|
-
${ctx}= Set Variable Lista filtrada por status Ativo.
|
|
119
|
-
${crit}= Set Variable Todos os itens visíveis mostram status Ativo?
|
|
120
|
-
${raw}= Gemini Evaluate With Screen ${ctx} ${crit}
|
|
121
|
-
Log ${raw}
|
|
122
|
-
```
|
|
123
|
-
|
|
124
|
-
Import explícito (equivalente):
|
|
125
|
-
|
|
126
|
-
```robot
|
|
127
|
-
Library robotframework_gemini.library.GeminiLibrary
|
|
128
|
-
```
|
|
129
|
-
|
|
130
|
-
Com arquivo já salvo:
|
|
131
|
-
|
|
132
|
-
```robot
|
|
133
|
-
Browser.Take Screenshot ${OUTPUT_DIR}/tela.png
|
|
134
|
-
${raw}= Gemini Evaluate With Image File ${ctx} ${crit} ${OUTPUT_DIR}/tela.png
|
|
135
|
-
```
|
|
136
|
-
|
|
137
|
-
Veredito via prompt (primeira linha) e nota 1–5:
|
|
138
|
-
|
|
139
|
-
```robot
|
|
140
|
-
${raw}= Gemini Evaluate With Screen ${ctx} ${crit}
|
|
141
|
-
... extra_instructions=Responda com uma palavra na primeira linha: Sim ou Não.
|
|
142
|
-
${v}= Get Line ${raw} 0
|
|
143
|
-
Should Be Equal As Strings ${v} Sim
|
|
144
|
-
|
|
145
|
-
${raw}= Gemini Evaluate Text Rating ${ctx} ${criterion}
|
|
146
|
-
${score}= Gemini Parse Rating ${raw}
|
|
147
|
-
```
|
|
148
|
-
|
|
149
|
-
Consulte também [`examples/demo_template.robot`](examples/demo_template.robot).
|
|
150
|
-
|
|
151
|
-
## Documentação de Keywords
|
|
152
|
-
|
|
153
|
-
- Português: [`docs/KEYWORDS.pt-BR.md`](docs/KEYWORDS.pt-BR.md)
|
|
154
|
-
- English: [`docs/KEYWORDS.en.md`](docs/KEYWORDS.en.md)
|
|
155
|
-
|
|
156
|
-
## Compatibilidade
|
|
157
|
-
|
|
158
|
-
- `BrowserGeminiLibrary` permanece como alias de `GeminiLibrary` para suítes existentes.
|
|
159
|
-
- Variáveis legadas (`LLM_API_KEY`, `LLM_API_KEY_LIA`, `LLM_LIA_MODEL`) são mapeadas para `GEMINI_*` ao importar o pacote.
|
|
160
|
-
|
|
161
|
-
## Testes
|
|
162
|
-
|
|
163
|
-
```bash
|
|
164
|
-
pytest
|
|
165
|
-
```
|
|
166
|
-
|
|
167
|
-
Os testes usam mocks de `generate_content`; não há chamadas reais à API.
|
|
168
|
-
|
|
169
|
-
## Licença
|
|
170
|
-
|
|
171
|
-
MIT.
|
|
@@ -1,137 +0,0 @@
|
|
|
1
|
-
# robotframework-gemini
|
|
2
|
-
|
|
3
|
-
Biblioteca **Python** e **keywords do Robot Framework** para oráculos com **Google Gemini**: avaliação **só texto** (API, logs, JSON, etc.) ou **multimodal** com imagem (arquivo PNG ou captura do **Robot Framework Browser**).
|
|
4
|
-
|
|
5
|
-
- **Multimodal**: envia o texto do prompt e a captura como `Part` em bytes (`google-genai`).
|
|
6
|
-
- **Fluxo recomendado**: duas entradas — **contexto** (enquadramento do teste) e **avaliação** (critério ou pergunta objetiva).
|
|
7
|
-
- **Browser opcional**: keywords de screenshot exigem `Library Browser`; keywords de texto funcionam sem navegador.
|
|
8
|
-
|
|
9
|
-
## Instalação
|
|
10
|
-
|
|
11
|
-
```bash
|
|
12
|
-
pip install robotframework-gemini
|
|
13
|
-
```
|
|
14
|
-
|
|
15
|
-
Com suporte a captura via Robot Framework Browser (Playwright):
|
|
16
|
-
|
|
17
|
-
```bash
|
|
18
|
-
pip install "robotframework-gemini[browser]"
|
|
19
|
-
python -m pip install robotframework
|
|
20
|
-
```
|
|
21
|
-
|
|
22
|
-
Desenvolvimento local:
|
|
23
|
-
|
|
24
|
-
```bash
|
|
25
|
-
python -m pip install -e ".[dev]"
|
|
26
|
-
```
|
|
27
|
-
|
|
28
|
-
## Variáveis de ambiente
|
|
29
|
-
|
|
30
|
-
| Variável | Função |
|
|
31
|
-
|-------------------|---------------------------------------------|
|
|
32
|
-
| `GEMINI_API_KEY` | Chave da API Gemini (obrigatória se não passar `api_key` na Library) |
|
|
33
|
-
| `GEMINI_MODEL` | Modelo (ex.: `gemini-2.0-flash`). Se omitido, usa `gemini-2.0-flash`. |
|
|
34
|
-
|
|
35
|
-
## Uso em Python (`GeminiOrchestrator`)
|
|
36
|
-
|
|
37
|
-
```python
|
|
38
|
-
from pathlib import Path
|
|
39
|
-
from robotframework_gemini import GeminiOrchestrator
|
|
40
|
-
|
|
41
|
-
orc = GeminiOrchestrator()
|
|
42
|
-
ctx = "Web dashboard with the 'Active' category filter applied."
|
|
43
|
-
crit = "Do the visible list items match the selected category?"
|
|
44
|
-
raw = orc.evaluate_with_image(ctx, crit, Path("screen.png"))
|
|
45
|
-
```
|
|
46
|
-
|
|
47
|
-
Para formato de saída restrito (ex.: Yes/No), use `extra_instructions`:
|
|
48
|
-
|
|
49
|
-
```python
|
|
50
|
-
raw = orc.evaluate_with_text(
|
|
51
|
-
ctx,
|
|
52
|
-
crit,
|
|
53
|
-
extra_instructions="Reply with one word only: Yes or No.",
|
|
54
|
-
)
|
|
55
|
-
```
|
|
56
|
-
|
|
57
|
-
## Uso no Robot Framework
|
|
58
|
-
|
|
59
|
-
### Só texto (sem Browser)
|
|
60
|
-
|
|
61
|
-
```robot
|
|
62
|
-
*** Settings ***
|
|
63
|
-
Library GeminiLibrary
|
|
64
|
-
|
|
65
|
-
*** Keywords ***
|
|
66
|
-
Validar resposta da API
|
|
67
|
-
${ctx}= Set Variable {"status": "ok", "items": 3}
|
|
68
|
-
${crit}= Set Variable O payload indica sucesso com itens?
|
|
69
|
-
${raw}= Gemini Evaluate Text ${ctx} ${crit}
|
|
70
|
-
Log ${raw}
|
|
71
|
-
```
|
|
72
|
-
|
|
73
|
-
### Com captura de tela (Browser)
|
|
74
|
-
|
|
75
|
-
Declare a biblioteca **Browser** antes de **Gemini**:
|
|
76
|
-
|
|
77
|
-
```robot
|
|
78
|
-
*** Settings ***
|
|
79
|
-
Library Browser
|
|
80
|
-
Library GeminiLibrary
|
|
81
|
-
|
|
82
|
-
*** Keywords ***
|
|
83
|
-
Checar tela por critério neutro
|
|
84
|
-
${ctx}= Set Variable Lista filtrada por status Ativo.
|
|
85
|
-
${crit}= Set Variable Todos os itens visíveis mostram status Ativo?
|
|
86
|
-
${raw}= Gemini Evaluate With Screen ${ctx} ${crit}
|
|
87
|
-
Log ${raw}
|
|
88
|
-
```
|
|
89
|
-
|
|
90
|
-
Import explícito (equivalente):
|
|
91
|
-
|
|
92
|
-
```robot
|
|
93
|
-
Library robotframework_gemini.library.GeminiLibrary
|
|
94
|
-
```
|
|
95
|
-
|
|
96
|
-
Com arquivo já salvo:
|
|
97
|
-
|
|
98
|
-
```robot
|
|
99
|
-
Browser.Take Screenshot ${OUTPUT_DIR}/tela.png
|
|
100
|
-
${raw}= Gemini Evaluate With Image File ${ctx} ${crit} ${OUTPUT_DIR}/tela.png
|
|
101
|
-
```
|
|
102
|
-
|
|
103
|
-
Veredito via prompt (primeira linha) e nota 1–5:
|
|
104
|
-
|
|
105
|
-
```robot
|
|
106
|
-
${raw}= Gemini Evaluate With Screen ${ctx} ${crit}
|
|
107
|
-
... extra_instructions=Responda com uma palavra na primeira linha: Sim ou Não.
|
|
108
|
-
${v}= Get Line ${raw} 0
|
|
109
|
-
Should Be Equal As Strings ${v} Sim
|
|
110
|
-
|
|
111
|
-
${raw}= Gemini Evaluate Text Rating ${ctx} ${criterion}
|
|
112
|
-
${score}= Gemini Parse Rating ${raw}
|
|
113
|
-
```
|
|
114
|
-
|
|
115
|
-
Consulte também [`examples/demo_template.robot`](examples/demo_template.robot).
|
|
116
|
-
|
|
117
|
-
## Documentação de Keywords
|
|
118
|
-
|
|
119
|
-
- Português: [`docs/KEYWORDS.pt-BR.md`](docs/KEYWORDS.pt-BR.md)
|
|
120
|
-
- English: [`docs/KEYWORDS.en.md`](docs/KEYWORDS.en.md)
|
|
121
|
-
|
|
122
|
-
## Compatibilidade
|
|
123
|
-
|
|
124
|
-
- `BrowserGeminiLibrary` permanece como alias de `GeminiLibrary` para suítes existentes.
|
|
125
|
-
- Variáveis legadas (`LLM_API_KEY`, `LLM_API_KEY_LIA`, `LLM_LIA_MODEL`) são mapeadas para `GEMINI_*` ao importar o pacote.
|
|
126
|
-
|
|
127
|
-
## Testes
|
|
128
|
-
|
|
129
|
-
```bash
|
|
130
|
-
pytest
|
|
131
|
-
```
|
|
132
|
-
|
|
133
|
-
Os testes usam mocks de `generate_content`; não há chamadas reais à API.
|
|
134
|
-
|
|
135
|
-
## Licença
|
|
136
|
-
|
|
137
|
-
MIT.
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{robotframework_gemini-0.2.0 → robotframework_gemini-0.3.1}/src/robotframework_gemini/legacy_env.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|