Implementation:0xSteph Pentest ai Playwright Chromium Fallback
| Knowledge Sources | |
|---|---|
| Domains | Playwright, Browser, Binary_Discovery |
| Last Updated | 2026-10-23 00:00 GMT |
Overview
Concrete tool for locating a usable Chromium binary when Playwright's pinned revision is missing, provided by the pentest-ai engine.
Description
The chromium_fallback function locates an executable Chromium binary when Playwright's pinned revision isn't installed. It checks PLAYWRIGHT_CHROMIUM_EXECUTABLE env var first, then walks PLAYWRIGHT_BROWSERS_PATH or ~/.cache/ms-playwright for binary names (chrome-headless-shell, headless_shell, chrome, chromium). Prefers headless variants and most recently modified binaries.
Usage
Import this function when you need a Chromium path for Playwright browser automation. Used by the browser agent to avoid failing when playwright install hasn't been run.
Code Reference
Source Location
- Repository: 0xSteph_Pentest_ai
- File: engine/playwright_chromium.py
- Lines: 1-40
Signature
def chromium_fallback() -> str | None:
"""Return an executable Chromium path, or None if none is usable."""
Import
from engine.playwright_chromium import chromium_fallback
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| PLAYWRIGHT_CHROMIUM_EXECUTABLE | str (env) | No | Explicit Chromium path |
| PLAYWRIGHT_BROWSERS_PATH | str (env) | No | Override browser cache root |
Outputs
| Name | Type | Description |
|---|---|---|
| path | None | Executable Chromium path, or None if not found |
Usage Examples
Get Chromium for Playwright
from engine.playwright_chromium import chromium_fallback
path = chromium_fallback()
if path:
print(f"Using Chromium at: {path}")
# browser = playwright.chromium.launch(executable_path=path)
else:
print("No Chromium found. Run: playwright install chromium")