LLM-Web-Pilot is a browser automation tool specifically designed for efficient interaction between humans and Large Language Models (LLMs). The primary goal is to provide a simple CLI interface that allows both humans and LLMs to easily control a web browser for various tasks: E2E testing, UI verification, routine automation, and other web interaction tasks.
- Node.js (v18 or higher)
- npm (usually comes with Node.js)
- Supported Browsers (Chromium, Firefox, WebKit) – installed automatically via Playwright
-
Ensure you have Node.js and npm installed:
node --version npm --version
-
Install dependencies:
npm install
-
Install Playwright browser binaries:
npx playwright install --with-deps
All tests and interactions are executed through self-contained scripts that manage the browser and server lifecycle.
A quick check to verify all core agent functions.
- Command:
bash examples/test-reference.sh - Verifies: clicks, text input,
localStorage, attributes, and checkboxes on a local test page.
- LLM-Oriented Interface: Simple commands understandable by both humans and LLMs, with uniform JSON responses.
- CI/CD Ready: Works out-of-the-box with GitHub Actions.
- Stability: Guaranteed process cleanup (PIDs) after execution.
- Diagnostics: Automatic screenshots and DOM dumps on failure.
- Human-Readable Errors: Provides clear messages and diagnostic artifacts when things go wrong.
The agent accepts a chain of commands separated by ;. It returns an array of results for each step.
- goto
url– Navigates to a URL (waits fordomcontentloaded). - click
selector– Clicks on an element. - type
selector text– Inputs text into a field. - waitElement
selector– Waits for element visibility (10s timeout).
- text
selector– GetsinnerText(defaults tobody). - getAttribute
selector attr– Gets the value of a specific element attribute. - isChecked
selector– Checks the state of a Checkbox/Radio button.
- localStorage
clear|set k v|key– Interact with Local Storage. - sessionStorage
clear|set k v|key– Interact with Session Storage.
- cookies
clear|set name value|name|-– Manage cookies (clear, set, get, or get all). - route
intercept pattern response|continue pattern– Intercept and mock network requests. - setOffline
true/false– Emulate network status. - security
headers|mixedContent|report– Security checks (headers, mixed content, full report).
- performance
metrics|timing– Retrieve performance metrics (Core Web Vitals, Navigation Timing). - screenshot
path|element selector path|fullpage path– Take a manual, element-specific, or full-page screenshot.
- file
upload selector path|download path– Upload/Download files. - mobile
emulate device|setViewport width height|getUserAgent– Mobile emulation (viewport, User Agent).
- worker
start [name]|postMessage name message|terminate name– Web Workers management. - serviceworker
register path|status|unregister– Service Worker management. - indexeddb
create name [version]|add dbname storename data|get dbname storename [key]|delete name– IndexedDB management. - waitServiceWorker – Wait for Service Worker activation.
- saveState
name– Saves browser state (cookies, localStorage, URL) tostates/<name>.json. - restoreState
name– Restores browser state fromstates/<name>.json(creates a new context, navigates to saved URL).
- custom
run command [params]|define name code– Define and run custom commands/plugins. - close – Shuts down the browser server.
If any command in a chain fails, the agent:
- Stops execution immediately.
- Captures a screenshot:
agent_error.png. - Dumps the full HTML source:
agent_error.html. - Returns a JSON object with the error description and paths to artifacts.
The agent always outputs results in a unified JSON format, optimized for LLM processing and human review:
{
"results": [
{ "status": "success", "action": "goto", "url": "..." },
{ "status": "success", "action": "click", "selector": "#btn" }
],
"pageErrors": []
}If pageErrors contains entries, it indicates that browser console exceptions occurred during execution. This allows LLMs to analyze the execution environment and adjust their actions accordingly.
For running multiple tests from a JSON file with shared setup/teardown:
node batch-runner.js tests/my-tests.json
node batch-runner.js tests/my-tests.json --tag=smoke
node batch-runner.js tests/my-tests.json --var=BASE_URL=http://localhost:3000 --format=pretty--tag=TAG– Run only tests that have the specified tag in theirtagsarray.--var=KEY=VALUE– Replace$KEYin setup/teardown/commands with VALUE. Can be repeated.--format=json|pretty– Output format.json(default) for machine parsing,prettyfor colored terminal output.
{
"setup": "goto $BASE_URL/app",
"teardown": "goto about:blank",
"tests": [
{
"name": "my-test-case",
"tags": ["smoke", "auth"],
"commands": "click #btn; text #result",
"expect": {
"results": [{ "status": "success" }, { "status": "success", "data": "Expected text" }]
}
}
]
}- setup – Command chain executed before each test (optional). Supports
$VARsubstitution. - teardown – Command chain executed after each test (optional). Supports
$VARsubstitution. - tags – Array of string tags for filtering with
--tag(optional). - expect – Partial match: only the specified fields are compared. Omitted fields are ignored.
The expect block supports special operators for flexible matching:
- Exact match (default):
"data": "hello"— value must equal"hello"exactly. $contains:"data": { "$contains": "SUCCESS" }— string must include the substring.$regex:"data": { "$regex": "v\\d+\\.\\d+", "$flags": "i" }— string must match the regex. Optional$flagsfor regex flags.
{
"total": 50,
"passed": 48,
"failed": 2,
"results": [
{ "name": "test-name", "status": "passed" },
{ "name": "test-name", "status": "failed", "expected": {}, "actual": {} }
]
}Save and restore browser state (cookies, localStorage, URL) to avoid repeating authentication flows:
# After completing login flow, save the state
node web-pilot.js "goto https://app.example.com; type #user admin; type #pass secret; click #login; saveState authenticated"
# In subsequent test runs, restore instead of re-authenticating
node web-pilot.js "restoreState authenticated; click #dashboard; text #welcome"State files are stored in the states/ directory as JSON.