playwriter -e
Execute JavaScript code in the browser via the relay server and exit. Requires a session ID fromplaywriter session new.
Options
Session ID (get one with
playwriter session new). Can also be set via PLAYWRITER_SESSION environment variable.JavaScript code to execute. Read https://playwriter.dev/SKILL.md for usage.
Execution timeout in milliseconds
Remote relay server host to connect to (or use
PLAYWRITER_HOST env var). If not specified, defaults to 127.0.0.1.Authentication token (or use
PLAYWRITER_TOKEN env var)Returns
Prints execution result to stdout:- Text output from the code
- Screenshot count if images were captured
- Errors to stderr if execution failed
Exit Codes
0- Code executed successfully1- Error during execution:- Missing session ID
- Cannot connect to relay server
- Code execution error
- Authentication failed
- Timeout exceeded
Examples
Error Messages
Missing session
Connection refused
HTTP errors
Notes
- The relay server starts automatically for local execution (when
--hostis not specified) - If the extension is not connected, you’ll see a warning but execution will attempt to continue
- Screenshots are captured as base64-encoded images in the response
- The current working directory is passed to the execution context