Skip to main content

Selenium Autopilot

Selenium Autopilot is a Python command-line tool and Selenium helper library for browser-test automation. It can turn written requirements into a structured test plan, generate a pytest/Selenium project from a reviewed plan, and analyze test failures to suggest locator repairs. Generated tests and repair suggestions require human review; the tool does not change your application or automatically apply fixes.

What you can do

  • Plan tests: Convert acceptance criteria, and optionally relevant source files, into prioritized test scenarios and a JSON plan.
  • Generate tests: Create pytest tests and Selenium Page Objects from a reviewed plan.
  • Investigate failures: Classify a failure report and, for locator failures, produce a proposed code diff.
  • Run browser tests: Use Selenium with Chrome, explicit waits, and useful failure diagnostics.
  • Report results: Convert JUnit XML to JSON and optionally publish a test summary to a GitHub pull request.

Requirements

  • Python 3.10 or newer
  • Google Chrome
  • An OpenAI-compatible provider for planning, generation, and locator proposals. A compatible local provider is also supported.

You do not need to clone or download this repository to use the package.

Install from PyPI

Install Selenium Autopilot in the Python environment where you want to use it:

python -m pip install selenium-autopilot

This installs the autopilot command and the Python dependencies. Check that it is available with:

autopilot --help

Configure an AI provider

Planning, test generation, and locator proposals use an OpenAI-compatible chat-completions API. By default, the tool uses the OpenAI API URL and the gpt-4o-mini model. Set your API key as an environment variable before running those commands.

PowerShell:

$env:AUTOPILOT_LLM_API_KEY = "your-api-key"

macOS or Linux:

export AUTOPILOT_LLM_API_KEY="your-api-key"

You can also configure a different endpoint and model with AUTOPILOT_LLM_BASE_URL and AUTOPILOT_LLM_MODEL. For example, a local OpenAI-compatible service might use:

AUTOPILOT_LLM_BASE_URL=http://localhost:11434/v1
AUTOPILOT_LLM_MODEL=your-local-model

Local HTTP is supported only for loopback addresses; remote providers must use HTTPS. Never put API keys, passwords, or other secrets in requirements, source files, or generated tests. Requirements and any source files you pass to plan are sent to the configured provider, so only share content you are permitted to share.

1. Write your requirements

Create a Markdown file describing what users should be able to do and what the application should show. Be specific about preconditions, actions, and expected results. Use an approved test environment and synthetic test data.

For example, save this as requirements.md:

# Sign-in requirements

- Given a valid test account, submitting its credentials signs the user in.
- After successful sign-in, the dashboard is displayed.
- Invalid credentials do not sign the user in.
- The application displays an error when sign-in is rejected.

If a behavior or expected message is not defined, say so. The planner records ambiguities rather than deciding what your application should do.

2. Create and review a test plan

autopilot plan --requirements requirements.md --output artifacts/test-plan.json

The plan contains a summary, prioritized scenarios, preconditions, steps, expected results, ambiguities, and risks. You can provide relevant source files as additional context; repeat --source for each file:

autopilot plan --requirements requirements.md --source src/login.py --output artifacts/test-plan.json

Review the plan before generating tests. If the output already exists, the command will not replace it unless you explicitly add --overwrite.

3. Generate a pytest/Selenium project

Generate tests from the reviewed plan:

autopilot generate --plan artifacts/test-plan.json --output generated_tests

The output includes a tests folder, Page Objects, a Chrome WebDriver fixture, and project setup files. Generated URLs, locators, test data, and assertions may need changes for your application. Review every generated file before running it; generation does not guarantee correct tests.

Install the generated project's dependencies and run its tests:

cd generated_tests
python -m pip install pytest selenium
python -m pytest

Use a non-production environment and approved test accounts. The generated fixture runs Chrome in headless mode. If the output already contains generated files, Autopilot refuses to replace them unless you pass --overwrite; review the existing files first.

4. Analyze a failure and request a locator proposal

To save browser diagnostics and a failure report when a test fails, run pytest with the Autopilot plugin enabled:

python -m pytest -p autopilot.pytest_plugin --junitxml=junit.xml

For failures that have a driver fixture, the plugin saves a screenshot, DOM snapshot, browser metadata, and failure-report.json under artifacts/diagnostics/ by default. You can change that location with AUTOPILOT_ARTIFACTS_DIR.

Classify a failure without an AI provider:

autopilot analyze --report artifacts/diagnostics/path-to-failure/failure-report.json --output artifacts/failure-analysis.json

For a locator-drift failure, request a proposed locator change:

autopilot heal --report artifacts/diagnostics/path-to-failure/failure-report.json --source tests/test_login.py --output artifacts/healing-proposal.json

The failure report must include the current locator_strategy and locator_value (for example, "css" and "#submit"). Add these fields to the report if they were not captured. The source file must contain the old locator as a single string value.

Healing creates a JSON proposal and diff; it does not edit the source file, change assertions, or rerun tests. The command-line workflow does not check the proposed locator against a live browser, so its uniqueness is reported as unchecked. Review the evidence and diff, verify the locator yourself, and apply an accepted change manually before rerunning the affected test and relevant regressions. Locator healing is not intended to fix application defects, invalid test data, or environment problems.

Other commands

  • autopilot report --junit junit.xml --output artifacts/test-results.json converts pytest's JUnit XML into a structured JSON report.
  • autopilot github-report --help shows options for publishing or updating a test-summary comment on a pull request. Set GITHUB_TOKEN and provide the repository and pull-request details.

Run autopilot --help or autopilot <command> --help for all available options. Output files are not overwritten by default; use --overwrite only after reviewing existing outputs.

Metadata

Release files for selenium-autopilot 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for selenium-autopilot 0.1.1
File Size Uploaded Provenance Actions
selenium_autopilot-0.1.1.tar.gz 39.0 kB With provenance Details for selenium_autopilot-0.1.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for selenium-autopilot 0.1.1
File Interpreter ABI Platform Actions
selenium_autopilot-0.1.1-py3-none-any.whl Python 3 none any Details for selenium_autopilot-0.1.1-py3-none-any.whl

Total release size: 74.2 kB

Release files / selenium_autopilot-0.1.1.tar.gz

Download URL selenium_autopilot-0.1.1.tar.gz
Size 39.0 kB
Tags Source
SHA-256 checksum
How to use checksums
fd2afaed9b95407d6535c0857bca206572d82445e782a05daaab2fa9ee4c9eeb
BLAKE2b-256 checksum
How to use checksums
8a27fc1d2939e671eee40308db0de58c906ae44933f0e5b1dcb2b4c3411c17b5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 1, 2026.

Transparency log

Release files / selenium_autopilot-0.1.1-py3-none-any.whl

Download URL selenium_autopilot-0.1.1-py3-none-any.whl
Size 35.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
817d26f7e964e34314da2de88067ceeb0df84f8856f761262a848102e1f06313
BLAKE2b-256 checksum
How to use checksums
3e7d74d3e19eeef717679ec98a74cc13515f26b43d2d84486fe804cfdab5fda7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 1, 2026.

Transparency log

Security for selenium-autopilot 0.1.1

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.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for selenium_autopilot-0.1.1.tar.gz

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 Nov 1, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page