The runner only makes outbound connections, to the TestDriver API and to Ably. You do not need to open an inbound port or expose the machine to the internet.
Choose your path
Prerequisites
Every machine that runs the runner needs:- Node.js 18 or newer
- Python 3 with
pyautoguiandPillow - A real, unlocked desktop session. The runner drives the mouse and keyboard, so the screen must be awake and not locked. Disable screen savers, sleep, and lock timers.
- Google Chrome on the
PATH, if your tests launch a browser - Outbound HTTPS and WebSocket access to
api.testdriver.aiand*.ably.io
- macOS
- Linux
- Windows
Platform notes
macOS: grant Accessibility and Screen Recording permissions
macOS: grant Accessibility and Screen Recording permissions
macOS blocks synthetic input and screen capture until you allow it explicitly. Without this the runner connects but every click and screenshot silently fails.Open System Settings → Privacy & Security and add your terminal application (Terminal, iTerm, or whichever app starts the runner) to both:
- Accessibility (lets the runner move the mouse and type)
- Screen Recording (lets the runner take screenshots)
Linux: provide a display
Linux: provide a display
The runner needs an X11 display. On a desktop machine, set To watch the session, add a VNC server and noVNC:Disable screen blanking so the desktop stays visible:
DISPLAY to your existing session. On a headless server, start a virtual framebuffer first:Windows: keep the console session active
Windows: keep the console session active
Run the runner in a console or RDP session that stays signed in. If the session locks or disconnects, the desktop is torn down and automation stops. Configure the machine to auto-logon and disable the lock screen timeout.
Step 1: Install the runner
testdriver-sandbox-agent, which connects your machine to a TestDriver session.
Verify the install:
Step 2: Register the machine
Ask the API for a session bound to your machine’s IP address:Pass
os: "linux" on macOS. The value only describes the session to the API; the runner detects the real platform itself.Write the config file
The runner reads its credentials from a JSON file on disk. CopysandboxId and the whole agent block into it:
/tmp/testdriver-agent.json
To put the file somewhere else, set
CONFIG_PATH to its full path before starting the runner.
Step 3: Start the runner
DISPLAY first:
Step 4: Point your test at the machine
Pass the machine’sip and the sandbox ID from step 2:
tests/my-machine.test.mjs
newSandbox: false stops the SDK from provisioning a cloud sandbox. Without it, your test runs in the cloud and ignores your machine.Each config file covers one session. The Ably token in it expires (see its
expires field), so repeat steps 2 and 3 to get fresh credentials before the next run.Logs
The runner also writes a status file next to the log (
testdriver-agent-status.json) with the sandbox ID, process ID, detected IP, and start time.
Security
- Use a dedicated machine or user account. The runner can click anything on the desktop and run shell commands sent by your tests. Do not point it at a machine holding personal credentials or production access.
- Treat the config file as a secret. It contains a session token and your API key.
- Do not expose VNC to the internet. If you add VNC for debugging, bind it to localhost or your VPN and tunnel in over SSH.
- Rotate your API key if a machine is decommissioned or shared.
Troubleshooting
Sandbox has expired and is no longer available
Sandbox has expired and is no longer available
The session ended, which happens when the runner stops or your test disconnects. Repeat step 2 to get a fresh sandbox ID and token, update the config file, restart the runner, and use the new ID in your test.
Runner starts but clicks and screenshots do nothing (macOS)
Runner starts but clicks and screenshots do nothing (macOS)
Accessibility or Screen Recording permission is missing. Add your terminal application to both lists under System Settings → Privacy & Security, then fully quit and reopen the terminal.
Waiting for config file
Waiting for config file
The runner cannot find
/tmp/testdriver-agent.json (or C:\Windows\Temp\testdriver-agent.json). Write the config file on the same machine and readable by the same user that starts the runner. To use a different location, set CONFIG_PATH.Test provisions a cloud sandbox instead of using my machine
Test provisions a cloud sandbox instead of using my machine
Pass
newSandbox: false to TestDriver() and make sure both ip and sandboxId reach connect(). If either is undefined, the SDK falls back to cloud provisioning.Invalid API key
Invalid API key
Confirm
TD_API_KEY matches the environment in TD_API_ROOT. Keys are scoped per environment. Get your key at console.testdriver.ai/team.Screenshots are blank or show a frozen desktop (Linux)
Screenshots are blank or show a frozen desktop (Linux)
DISPLAY points at a display with no desktop running, or the screen blanked. Start a desktop on that display and disable blanking with xset s off && xset s noblank && xset -dpms.
