Build a Self-Running QA Testing Bot with the Computer Use API
Traditional QA automation relies on brittle selectors and page IDs that break when the UI changes. You can write a QA bot that watches the screen, clicks, types, and reads values like a human does. It uses the computer use API to drive a real browser or desktop, runs automatically until done, and streams events so you can integrate it into CI pipelines. You pay $0.05 per agent step on cloud machines you provision.
How the QA bot works
The bot starts by provisioning a cloud machine with POST /v1/machines. The machine returns a machine_id you use in a task run. You POST /v1/runs with the machine_id, a task that describes the QA steps, and optional instructions. The server spins up an agent that drives the desktop in loops: capture a screenshot, POST /v1/predict with the screenshot base64, the instruction, and cua_version, then act on the returned actions. The run progresses through states, queued, running, awaiting_human, succeeded, failed, cancelled, timed_out. Events from POST /v1/runs/{id}/events stream progress so you can update your UI or trigger a webhook. The task is complete when the run reaches succeeded or failed.
#!/usr/bin/env bash
set -euo pipefail
COASTY_API_KEY="${COASTY_API_KEY}"
# Provision a cloud machine
MACHINE_RESPONSE=$(curl -s -X POST https://coasty.ai/v1/machines \
-H "X-API-Key: $COASTY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "qa-bot-machine",
"image": "ubuntu-24.04",
"size": "small"
}')
MACHINE_ID=$(echo "$MACHINE_RESPONSE" | jq -r '.machine_id')
echo "Provisioned machine: $MACHINE_ID"
# Start a QA run (browser-based click flow)
RUN_RESPONSE=$(curl -s -X POST https://coasty.ai/v1/runs \
-H "X-API-Key: $COASTY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"machine_id": "'"$MACHINE_ID"'",
"task": "Open the browser, navigate to https://example.com, click the link that says About, and assert the page title contains About",
"cua_version": "v3",
"max_steps": 60,
"deadline_seconds": 300,
"on_awaiting_human": "pause"
}')
RUN_ID=$(echo "$RUN_RESPONSE" | jq -r '.run_id')
echo "Started run: $RUN_ID"
# Stream events while the run is active
curl -s -N -X GET "https://coasty.ai/v1/runs/$RUN_ID/events" \
-H "X-API-Key: $COASTY_API_KEY" \
--header "Accept: text/event-stream" \
| while IFS= read -r line; do
echo "$line"
if echo "$line" | grep -q "Data: {\"status\":\"succeeded\"}"; then
echo "QA run succeeded."
exit 0
elif echo "$line" | grep -q "Data: {\"status\":\"failed\"}"; then
echo "QA run failed."
exit 1
fi
done
# Clean up (stop the machine)
curl -s -X POST "https://coasty.ai/v1/machines/$MACHINE_ID/stop" \
-H "X-API-Key: $COASTY_API_KEY"Key fields and pricing
- ●POST /v1/machines provisions a cloud VM with an image and size; returns machine_id.
- ●POST /v1/runs drives the QA agent with machine_id, task (natural language steps), cua_version (v3 or v4), max_steps, deadline_seconds, and on_awaiting_human.
- ●GET /v1/runs/{id}/events streams Server-Sent Events; reconnect with Last-Event-ID.
- ●Each agent step on a task run costs $0.05. Machine provision is billed separately per unit time.
- ●States are queued, running, awaiting_human, succeeded, failed, cancelled, timed_out.
POST /v1/runs with machine_id and a natural-language task is the simplest way to spin up a self-running QA bot.
Where this beats brittle automation
Traditional tools rely on CSS selectors or XPath that break when a class or ID changes. The computer use API reads the screen and treats UI elements like a human does. It can click a link by its text, fill a form by placeholder, and verify a success message or status code. It also works on desktop apps and terminals where no DOM exists. Instead of brittle selectors, your QA bot watches the visual result and acts accordingly.
Next steps
Extend the bot to run as a scheduled workflow that provisions a machine, executes multiple test steps, and cleans up automatically. Use the parse endpoint (free) to turn existing pyautogui scripts into structured actions, then wrap them in a workflow with asserts and loops. Get your API key at https://coasty.ai/developers and start building a self-running QA bot that works like a human.