Skip to content

[Feature] πŸ” Auto-Login / Auth State Management β€” Automatic session handlingΒ #3

Description

@khaledbourghida

Problem Statement

Authentication is the #1 friction point in E2E testing. Every team that evaluates Specter will hit "but my app requires login" within the first 5 minutes. Currently, if the target app requires authentication, the user must manually log in before running tests, and the session may expire mid-suite.

Proposed Solution

Specter should automatically:

  1. Detect login pages (URL contains /login, /signin, presence of <input type="password">)
  2. Execute a configurable login scenario before the test suite
  3. Persist the auth state using Playwright's context.storageState()
  4. Reuse the saved state for all subsequent test contexts via browser.newContext({ storageState })

Implementation Notes

  • Playwright's context.storageState({ path: 'auth.json' }) and browser.newContext({ storageState: 'auth.json' }) are first-class APIs β€” no hacking needed.
  • Login detection heuristic in browserExecutor.js: check the current URL for /login, /signin, /auth, or scan the DOM for <input type="password">.
  • Store auth state in the .ai-agent-cache/ directory (already gitignored).
  • Auth credentials come from the environments config (see Multi-Environment issue) or a dedicated auth section in settings.json.
  • The coordinator.js pipeline should insert a "login check" step before the main test suite β€” between routeNavigator and scenarioWriter.

Auth Flow

coordinator starts ↓ routeNavigator β†’ navigates to target ↓ loginDetector β†’ checks if page is a login screen β”œβ”€ NO β†’ continue to scenarioWriter └─ YES β†’ run login scenario β†’ save storageState β†’ continue

Which Agent / Component Does This Affect?

  • Code Analyst
  • Route Navigator
  • Selector Expert
  • Scenario Writer
  • Script Writer
  • Browser Executor
  • Verifier / Step Fixer
  • Cache / SQLite layer
  • UI / Client
  • Configuration / Settings
  • Other: New loginDetector utility or agent

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions