Have an agent write Playwright tests
Give a coding agent the Appetize CLI and have it explore your app on a device, then write and run Playwright tests that pass.
A coding agent can write your mobile tests. You create an API token. The agent installs the CLI, uploads the app, finds what it can select on each screen, and writes the Playwright tests.
This example uses the TODO app. It works with Claude Code, Codex, Copilot, Cursor, and any other agent that runs terminal commands.
1. Create a token
The agent can install the tools and build the project. It cannot create your API token.
Node 22 or later needs to be available. Create a token under Organization → API Tokens, then export it in the environment your agent uses:
export APPETIZE_API_TOKEN=tok_xxxxxxxxxxxxIf your Appetize URL is not https://appetize.io, also set APPETIZE_ENDPOINT to that URL.
2. Ask your agent
Open an empty folder in your agent and give it the task:
Install the Appetize CLI and its skill. The CLI is documented at https://docs.appetize.io/ai-agents/getting-started.
Create Playwright tests for the TODO app with
@appetize/playwright. Upload the app with the Appetize CLI.Cover these flows:
the Overdue filter
opening a task with
todoapp://task/deeplinkadding a task with
todoapp://newRun the tests until they pass. Use https://docs.appetize.io/testing/writing-tests for the test API.
Open the viewerUrl the agent prints to watch the device while it works.
3. What the agent does
Installs the CLI and its skill, creates the Playwright project, and uploads the app.
Drives the three flows on a device.
Writes a test for each flow and runs the suite.
4. What you get
A resulting test file can look like this:
Your agent's file will be different, but it should cover the same three flows.
To run them on every push, see Run Playwright in CI.
Doing it by hand
The agent only runs CLI commands, so you can run the same steps yourself. Each command maps to one Playwright call:
appetize tap --select-text 'Overdue'
session.tap({ element: { attributes: { text: 'Overdue' } } })
appetize open 'todoapp://…'
session.openUrl('todoapp://…')
appetize swipe --direction up
session.swipe({ position: { x: '50%', y: '50%' }, gesture: 'up' })
appetize inspect --select-text 'Buy milk'
expect(session).toHaveElement({ attributes: { text: 'Buy milk' } })
To list every command, run appetize --help. To see the flags and examples for one command, add --help to it, for example appetize tap --help. The AI Agents docs cover the CLI in more detail.
Last updated