selenium-python-ai-agent 0.2.0__tar.gz → 0.2.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.
Files changed (42) hide show
  1. {selenium_python_ai_agent-0.2.0/selenium_python_ai_agent.egg-info → selenium_python_ai_agent-0.2.1}/PKG-INFO +11 -5
  2. {selenium_python_ai_agent-0.2.0 → selenium_python_ai_agent-0.2.1}/README.md +10 -4
  3. {selenium_python_ai_agent-0.2.0 → selenium_python_ai_agent-0.2.1}/pyproject.toml +1 -1
  4. {selenium_python_ai_agent-0.2.0 → selenium_python_ai_agent-0.2.1}/selenium_agent/__init__.py +1 -1
  5. {selenium_python_ai_agent-0.2.0 → selenium_python_ai_agent-0.2.1}/selenium_agent/cli.py +32 -4
  6. {selenium_python_ai_agent-0.2.0 → selenium_python_ai_agent-0.2.1}/selenium_agent/utils/config_manager.py +1 -0
  7. {selenium_python_ai_agent-0.2.0 → selenium_python_ai_agent-0.2.1}/selenium_agent/utils/llm.py +20 -0
  8. {selenium_python_ai_agent-0.2.0 → selenium_python_ai_agent-0.2.1/selenium_python_ai_agent.egg-info}/PKG-INFO +11 -5
  9. {selenium_python_ai_agent-0.2.0 → selenium_python_ai_agent-0.2.1}/tests/test_agent_enhancements.py +25 -0
  10. {selenium_python_ai_agent-0.2.0 → selenium_python_ai_agent-0.2.1}/tests/test_path_handling.py +1 -1
  11. {selenium_python_ai_agent-0.2.0 → selenium_python_ai_agent-0.2.1}/LICENSE +0 -0
  12. {selenium_python_ai_agent-0.2.0 → selenium_python_ai_agent-0.2.1}/selenium_agent/agents/__init__.py +0 -0
  13. {selenium_python_ai_agent-0.2.0 → selenium_python_ai_agent-0.2.1}/selenium_agent/agents/coder.py +0 -0
  14. {selenium_python_ai_agent-0.2.0 → selenium_python_ai_agent-0.2.1}/selenium_agent/agents/definitions.py +0 -0
  15. {selenium_python_ai_agent-0.2.0 → selenium_python_ai_agent-0.2.1}/selenium_agent/agents/healer.py +0 -0
  16. {selenium_python_ai_agent-0.2.0 → selenium_python_ai_agent-0.2.1}/selenium_agent/agents/planner.py +0 -0
  17. {selenium_python_ai_agent-0.2.0 → selenium_python_ai_agent-0.2.1}/selenium_agent/bdd/__init__.py +0 -0
  18. {selenium_python_ai_agent-0.2.0 → selenium_python_ai_agent-0.2.1}/selenium_agent/bdd/gherkin_advisor.py +0 -0
  19. {selenium_python_ai_agent-0.2.0 → selenium_python_ai_agent-0.2.1}/selenium_agent/bdd/templates.py +0 -0
  20. {selenium_python_ai_agent-0.2.0 → selenium_python_ai_agent-0.2.1}/selenium_agent/core/__init__.py +0 -0
  21. {selenium_python_ai_agent-0.2.0 → selenium_python_ai_agent-0.2.1}/selenium_agent/core/orchestrator.py +0 -0
  22. {selenium_python_ai_agent-0.2.0 → selenium_python_ai_agent-0.2.1}/selenium_agent/scanner/__init__.py +0 -0
  23. {selenium_python_ai_agent-0.2.0 → selenium_python_ai_agent-0.2.1}/selenium_agent/scanner/project_scanner.py +0 -0
  24. {selenium_python_ai_agent-0.2.0 → selenium_python_ai_agent-0.2.1}/selenium_agent/selenium/__init__.py +0 -0
  25. {selenium_python_ai_agent-0.2.0 → selenium_python_ai_agent-0.2.1}/selenium_agent/selenium/base_page.py +0 -0
  26. {selenium_python_ai_agent-0.2.0 → selenium_python_ai_agent-0.2.1}/selenium_agent/selenium/driver_factory.py +0 -0
  27. {selenium_python_ai_agent-0.2.0 → selenium_python_ai_agent-0.2.1}/selenium_agent/selenium/error_map.py +0 -0
  28. {selenium_python_ai_agent-0.2.0 → selenium_python_ai_agent-0.2.1}/selenium_agent/selenium/locator_advisor.py +0 -0
  29. {selenium_python_ai_agent-0.2.0 → selenium_python_ai_agent-0.2.1}/selenium_agent/selenium/locator_scanner.py +0 -0
  30. {selenium_python_ai_agent-0.2.0 → selenium_python_ai_agent-0.2.1}/selenium_agent/utils/__init__.py +0 -0
  31. {selenium_python_ai_agent-0.2.0 → selenium_python_ai_agent-0.2.1}/selenium_agent/utils/code_validator.py +0 -0
  32. {selenium_python_ai_agent-0.2.0 → selenium_python_ai_agent-0.2.1}/selenium_agent/utils/json_utils.py +0 -0
  33. {selenium_python_ai_agent-0.2.0 → selenium_python_ai_agent-0.2.1}/selenium_agent/utils/logger.py +0 -0
  34. {selenium_python_ai_agent-0.2.0 → selenium_python_ai_agent-0.2.1}/selenium_agent/utils/paths.py +0 -0
  35. {selenium_python_ai_agent-0.2.0 → selenium_python_ai_agent-0.2.1}/selenium_agent/utils/spec_writer.py +0 -0
  36. {selenium_python_ai_agent-0.2.0 → selenium_python_ai_agent-0.2.1}/selenium_agent/utils/url_extractor.py +0 -0
  37. {selenium_python_ai_agent-0.2.0 → selenium_python_ai_agent-0.2.1}/selenium_python_ai_agent.egg-info/SOURCES.txt +0 -0
  38. {selenium_python_ai_agent-0.2.0 → selenium_python_ai_agent-0.2.1}/selenium_python_ai_agent.egg-info/dependency_links.txt +0 -0
  39. {selenium_python_ai_agent-0.2.0 → selenium_python_ai_agent-0.2.1}/selenium_python_ai_agent.egg-info/entry_points.txt +0 -0
  40. {selenium_python_ai_agent-0.2.0 → selenium_python_ai_agent-0.2.1}/selenium_python_ai_agent.egg-info/requires.txt +0 -0
  41. {selenium_python_ai_agent-0.2.0 → selenium_python_ai_agent-0.2.1}/selenium_python_ai_agent.egg-info/top_level.txt +0 -0
  42. {selenium_python_ai_agent-0.2.0 → selenium_python_ai_agent-0.2.1}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: selenium-python-ai-agent
3
- Version: 0.2.0
3
+ Version: 0.2.1
4
4
  Summary: AI-powered multi-agent framework to plan, generate and heal Selenium Python tests (pytest + pytest-bdd)
5
5
  Author: Ankit Tripathi
6
6
  License: MIT
@@ -135,11 +135,17 @@ selenium-agent --heal-only generated_tests/tests/test_checkout.py
135
135
  Most teams don't start from scratch — they already have a Selenium project. Point the agent at it with `--project` and it **adapts to your structure instead of imposing its own**:
136
136
 
137
137
  ```bash
138
- # First, see what the scanner detects about your project (read-only)
138
+ # First, see what the scanner detects about your project (read-only).
139
+ # The path is SAVED to config — you never need to repeat it.
139
140
  selenium-agent --scan /path/to/your/project
140
141
 
141
- # Then generate tests that FIT INTO it
142
- selenium-agent "test the invoice creation flow" --project /path/to/your/project
142
+ # From now on every run fits into it automatically:
143
+ selenium-agent "test the invoice creation flow"
144
+ selenium-agent "test the user permissions page"
145
+
146
+ # Manage the saved project:
147
+ selenium-agent config --project /other/project # switch
148
+ selenium-agent config --project none # clear
143
149
  ```
144
150
 
145
151
  The built-in **ProjectScanner** detects and follows:
@@ -359,7 +365,7 @@ generated_tests/
359
365
  | `--headless` | Headless browser | from config (`false`) |
360
366
  | `--explore N` | Explore up to N extra same-origin pages while planning (relevance-ranked, multi-hop) | `0` |
361
367
  | `--output-dir` | Where to save generated files | `generated_tests` |
362
- | `--project` | Fit into existing project path | — |
368
+ | `--project` | Existing project path (saved to config set once) | from config |
363
369
  | `--max-retries` | Healer fix attempts | `5` |
364
370
  | `--no-heal` | Skip healing after codegen | `false` |
365
371
  | `--plan-only` | Save + show plan, no code | `false` |
@@ -105,11 +105,17 @@ selenium-agent --heal-only generated_tests/tests/test_checkout.py
105
105
  Most teams don't start from scratch — they already have a Selenium project. Point the agent at it with `--project` and it **adapts to your structure instead of imposing its own**:
106
106
 
107
107
  ```bash
108
- # First, see what the scanner detects about your project (read-only)
108
+ # First, see what the scanner detects about your project (read-only).
109
+ # The path is SAVED to config — you never need to repeat it.
109
110
  selenium-agent --scan /path/to/your/project
110
111
 
111
- # Then generate tests that FIT INTO it
112
- selenium-agent "test the invoice creation flow" --project /path/to/your/project
112
+ # From now on every run fits into it automatically:
113
+ selenium-agent "test the invoice creation flow"
114
+ selenium-agent "test the user permissions page"
115
+
116
+ # Manage the saved project:
117
+ selenium-agent config --project /other/project # switch
118
+ selenium-agent config --project none # clear
113
119
  ```
114
120
 
115
121
  The built-in **ProjectScanner** detects and follows:
@@ -329,7 +335,7 @@ generated_tests/
329
335
  | `--headless` | Headless browser | from config (`false`) |
330
336
  | `--explore N` | Explore up to N extra same-origin pages while planning (relevance-ranked, multi-hop) | `0` |
331
337
  | `--output-dir` | Where to save generated files | `generated_tests` |
332
- | `--project` | Fit into existing project path | — |
338
+ | `--project` | Existing project path (saved to config set once) | from config |
333
339
  | `--max-retries` | Healer fix attempts | `5` |
334
340
  | `--no-heal` | Skip healing after codegen | `false` |
335
341
  | `--plan-only` | Save + show plan, no code | `false` |
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "selenium-python-ai-agent"
7
- version = "0.2.0"
7
+ version = "0.2.1"
8
8
  description = "AI-powered multi-agent framework to plan, generate and heal Selenium Python tests (pytest + pytest-bdd)"
9
9
  readme = "README.md"
10
10
  license = { text = "MIT" }
@@ -15,6 +15,6 @@ Usage (CLI):
15
15
 
16
16
  from selenium_agent.core.orchestrator import Orchestrator as SeleniumAgent
17
17
 
18
- __version__ = "0.2.0"
18
+ __version__ = "0.2.1"
19
19
  __author__ = "Ankit Tripathi"
20
20
  __all__ = ["SeleniumAgent"]
@@ -27,6 +27,8 @@ def _handle_config(argv):
27
27
  p.add_argument("--headless", dest="headless", action="store_true", default=None)
28
28
  p.add_argument("--no-headless", dest="headless", action="store_false", default=None)
29
29
  p.add_argument("--mode", choices=["pytest", "bdd"])
30
+ p.add_argument("--project", help="Existing project to fit tests into "
31
+ "(use 'none' to clear)")
30
32
  p.add_argument("--show", action="store_true", help="Print current config")
31
33
  args = p.parse_args(argv)
32
34
 
@@ -35,6 +37,9 @@ def _handle_config(argv):
35
37
  print(json.dumps(config_manager.load(), indent=2))
36
38
  return
37
39
 
40
+ if args.project and args.project.lower() in ("none", "clear", "off"):
41
+ args.project = "" # empty string clears it (consumers treat "" as unset)
42
+
38
43
  updates = {k: v for k, v in vars(args).items() if v is not None and k != "show"}
39
44
  if not updates:
40
45
  p.print_help()
@@ -115,8 +120,8 @@ def _handle_help():
115
120
  --headless headless browser
116
121
  --explore N scan N extra same-origin pages while planning
117
122
  --output-dir where to save files (default: generated_tests)
118
- --project path to existing project
119
- --max-retries healer retries (default: 3)
123
+ --project existing project path (auto-saved to config)
124
+ --max-retries healer retries (default: 5)
120
125
  --no-heal skip healing
121
126
  --plan-only preview plan only (saved to specs/)
122
127
  --from-plan generate from saved plan JSON
@@ -196,7 +201,7 @@ Other examples:
196
201
  parser.add_argument("--test", default=None, metavar="TEST_NAME",
197
202
  help="Specific test function to run/heal. "
198
203
  "e.g. --test test_login_locked_out_user")
199
- parser.add_argument("--version", action="version", version="selenium-agent 0.2.0")
204
+ parser.add_argument("--version", action="version", version="selenium-agent 0.2.1")
200
205
 
201
206
  args = parser.parse_args()
202
207
 
@@ -210,6 +215,11 @@ Other examples:
210
215
  except Exception as e:
211
216
  print(f"❌ Scan failed: {e}")
212
217
  sys.exit(1)
218
+ # Remember the project — future runs fit into it automatically,
219
+ # no need to repeat --project every time.
220
+ config_manager.save({"project": args.scan})
221
+ print(f"\n💾 Project saved to config — future runs will fit into it.")
222
+ print(f" (change: selenium-agent config --project <path> | clear: --project none)")
213
223
  sys.exit(0)
214
224
 
215
225
  # ── Merge config + CLI args ───────────────────────────────────────
@@ -220,6 +230,16 @@ Other examples:
220
230
  "mode": args.mode,
221
231
  })
222
232
 
233
+ # `--model gpt-5` without `--provider` must not hit the default
234
+ # (Anthropic) API — the model name itself tells us the provider.
235
+ # An explicit --provider flag always wins.
236
+ if args.provider is None and cfg.get("model"):
237
+ from selenium_agent.utils.llm import infer_provider_for_model
238
+ inferred = infer_provider_for_model(cfg["model"])
239
+ if inferred and inferred != cfg.get("provider"):
240
+ logger.info(f"🧭 Model '{cfg['model']}' implies provider '{inferred}'")
241
+ cfg["provider"] = inferred
242
+
223
243
  # URL priority: --url flag > extracted from instruction > saved base_url
224
244
  from selenium_agent.utils.url_extractor import extract_url
225
245
  override_url = args.url
@@ -235,6 +255,14 @@ Other examples:
235
255
  config_manager.save({"base_url": args.url})
236
256
  logger.info(f"💾 base_url saved: {args.url}")
237
257
 
258
+ # Project priority: --project flag > saved config. Persist like --url.
259
+ project_root = args.project or (cfg.get("project") or None)
260
+ if args.project and args.project != cfg.get("project"):
261
+ config_manager.save({"project": args.project})
262
+ logger.info(f"💾 project saved: {args.project}")
263
+ elif not args.project and project_root:
264
+ logger.info(f"🏗️ Using saved project: {project_root}")
265
+
238
266
  # ── Build orchestrator ────────────────────────────────────────────
239
267
  try:
240
268
  agent = Orchestrator(
@@ -245,7 +273,7 @@ Other examples:
245
273
  max_heal_retries=args.max_retries or 5,
246
274
  auto_heal=not args.no_heal,
247
275
  mode=cfg["mode"],
248
- project_root=args.project,
276
+ project_root=project_root,
249
277
  headless=cfg["headless"],
250
278
  explore_pages=args.explore,
251
279
  )
@@ -23,6 +23,7 @@ DEFAULTS = {
23
23
  "headless": False,
24
24
  "mode": "pytest",
25
25
  "base_url": None, # persisted across runs — no need to pass --url repeatedly
26
+ "project": None, # persisted by --scan/--project — fit into this project automatically
26
27
  }
27
28
 
28
29
 
@@ -37,6 +37,26 @@ _NON_RETRYABLE = (
37
37
  )
38
38
 
39
39
 
40
+ def infer_provider_for_model(model: str | None) -> str | None:
41
+ """
42
+ Infer the provider from a model name — 'gpt-5' implies OpenAI,
43
+ 'claude-fable-5' implies Anthropic.
44
+
45
+ Fresh installs have no saved config, so `--model gpt-5` without
46
+ `--provider openai` would otherwise send an OpenAI model to the
47
+ default (Anthropic) API and fail with a confusing auth/model error.
48
+ Returns None when the name matches no known family.
49
+ """
50
+ if not model:
51
+ return None
52
+ m = model.strip().lower()
53
+ if m.startswith(("gpt-", "o1", "o3", "o4", "chatgpt")):
54
+ return "openai"
55
+ if m.startswith("claude"):
56
+ return "anthropic"
57
+ return None
58
+
59
+
40
60
  def normalize_provider(provider: str | None) -> str:
41
61
  normalized = (provider or DEFAULT_PROVIDER).strip().lower()
42
62
  if normalized not in API_KEY_ENV_VARS:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: selenium-python-ai-agent
3
- Version: 0.2.0
3
+ Version: 0.2.1
4
4
  Summary: AI-powered multi-agent framework to plan, generate and heal Selenium Python tests (pytest + pytest-bdd)
5
5
  Author: Ankit Tripathi
6
6
  License: MIT
@@ -135,11 +135,17 @@ selenium-agent --heal-only generated_tests/tests/test_checkout.py
135
135
  Most teams don't start from scratch — they already have a Selenium project. Point the agent at it with `--project` and it **adapts to your structure instead of imposing its own**:
136
136
 
137
137
  ```bash
138
- # First, see what the scanner detects about your project (read-only)
138
+ # First, see what the scanner detects about your project (read-only).
139
+ # The path is SAVED to config — you never need to repeat it.
139
140
  selenium-agent --scan /path/to/your/project
140
141
 
141
- # Then generate tests that FIT INTO it
142
- selenium-agent "test the invoice creation flow" --project /path/to/your/project
142
+ # From now on every run fits into it automatically:
143
+ selenium-agent "test the invoice creation flow"
144
+ selenium-agent "test the user permissions page"
145
+
146
+ # Manage the saved project:
147
+ selenium-agent config --project /other/project # switch
148
+ selenium-agent config --project none # clear
143
149
  ```
144
150
 
145
151
  The built-in **ProjectScanner** detects and follows:
@@ -359,7 +365,7 @@ generated_tests/
359
365
  | `--headless` | Headless browser | from config (`false`) |
360
366
  | `--explore N` | Explore up to N extra same-origin pages while planning (relevance-ranked, multi-hop) | `0` |
361
367
  | `--output-dir` | Where to save generated files | `generated_tests` |
362
- | `--project` | Fit into existing project path | — |
368
+ | `--project` | Existing project path (saved to config set once) | from config |
363
369
  | `--max-retries` | Healer fix attempts | `5` |
364
370
  | `--no-heal` | Skip healing after codegen | `false` |
365
371
  | `--plan-only` | Save + show plan, no code | `false` |
@@ -333,3 +333,28 @@ def test_token_budget_uses_structure_not_keywords():
333
333
  "locators": [],
334
334
  }
335
335
  assert coder._token_budget(big) == 12000
336
+
337
+
338
+ def test_infer_provider_from_model_name():
339
+ from selenium_agent.utils.llm import infer_provider_for_model
340
+
341
+ assert infer_provider_for_model("gpt-5") == "openai"
342
+ assert infer_provider_for_model("gpt-4o-mini") == "openai"
343
+ assert infer_provider_for_model("o3-mini") == "openai"
344
+ assert infer_provider_for_model("claude-fable-5") == "anthropic"
345
+ assert infer_provider_for_model("claude-sonnet-5") == "anthropic"
346
+ assert infer_provider_for_model("some-unknown-model") is None
347
+ assert infer_provider_for_model(None) is None
348
+
349
+
350
+ def test_config_persists_project(tmp_path: Path, monkeypatch: pytest.MonkeyPatch):
351
+ from selenium_agent.utils import config_manager
352
+
353
+ monkeypatch.chdir(tmp_path)
354
+ config_manager.save({"project": "/path/to/my/framework"})
355
+ cfg = config_manager.load()
356
+ assert cfg["project"] == "/path/to/my/framework"
357
+
358
+ # Clearing: empty string is treated as unset by consumers
359
+ config_manager.save({"project": ""})
360
+ assert (config_manager.load()["project"] or None) is None
@@ -25,7 +25,7 @@ def make_healer(output_dir: Path) -> HealerAgent:
25
25
 
26
26
 
27
27
  def test_package_import_exposes_public_api():
28
- assert selenium_agent.__version__ == "0.2.0"
28
+ assert selenium_agent.__version__ == "0.2.1"
29
29
  assert selenium_agent.SeleniumAgent.__name__ == "Orchestrator"
30
30
 
31
31