Tutorial

Build a Self-Running QA Testing Bot with the Computer Use API

Marcus Sterling||12 min
Ctrl+A

Writing UI tests that stay in sync when your app changes is hard. Classical selectors break, and API-only checks miss visual glitches. The computer use API lets you build a QA bot that sees the screen, reads errors, and acts like a human to verify or fix issues. You provision a cloud VM, send a task, and get a pass/fail result without writing a single selector.

How it works

A QA bot with the computer use API follows this flow. First you create a machine, that is a cloud VM with a desktop or browser. Then you POST /v1/runs with your test specification. The server drives a computer use agent on that machine. The agent captures screenshots, predicts actions, and interacts with the UI until the task completes. You get a final status of succeeded, failed, cancelled, or timed_out. Each agent step costs $0.05. For autonomous runs you can request cua_version "v4" which includes a built-in pass/fail verifier.

bash
#!/usr/bin/env bash
# Create a machine and run a QA task in one request

COASTY_API_KEY=${COASTY_API_KEY:-$HOME/.coasty/key}

machine_res=$(curl -s -X POST https://coasty.ai/v1/machines \
  -H "X-API-Key: $COASTY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "display": "1280x720",
    "os": "linux",
    "type": "desktop"
  }')

machine_id=$(echo "$machine_res" | jq -r '.id')

task_res=$(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 https://example.com, click the link that contains "Learn more", then assert the title starts with "Example Domain".",
    "cua_version": "v4",
    "max_steps": 20
  }')

run_id=$(echo "$task_res" | jq -r '.id')

echo "Run started: $run_id"

echo "Waiting for state..."
while true; do
  status=$(curl -s -X GET "https://coasty.ai/v1/runs/$run_id" \
    -H "X-API-Key: $COASTY_API_KEY" | jq -r '.state')
  echo "Status: $status"
  if [[ "$status" == "succeeded" || "$status" == "failed" || "$status" == "cancelled" ]]; then
    break
  fi
  sleep 2
done

echo "Final result: $status"

Key fields and pricing

  • POST /v1/machines creates a cloud VM with display and OS. The response includes an id you pass to runs.
  • POST /v1/runs starts a QA task. Required fields are machine_id, task, and cua_version ("v3" or "v4"). Optional instructions, system_prompt, max_steps, deadline_seconds, on_awaiting_human, and webhook_url.
  • Each agent step costs $0.05. The v4 agent runs with a built-in pass/fail verifier.
  • GET /v1/runs/{id} shows state: queued, running, awaiting_human, succeeded, failed, cancelled, timed_out.
  • GET /v1/runs/{id}/events streams Server-Sent Events for real-time logs. Reconnect with Last-Event-ID header.

One POST /v1/runs creates the machine, launches the QA bot, and returns a run id you can poll until succeeded or failed.

Where this beats brittle automation

Traditional test frameworks rely on CSS selectors, IDs, or XPath that break when layout or text changes. A computer use agent sees the screen, so it can locate elements by context, color, or layout. It can read error messages, confirm button states, and click in ways that match how a human interacts. This makes regression tests resilient to design changes and UI churn. You also get cross-browser and cross-OS coverage because the agent runs on cloud VMs with full desktop environments.

Next steps and getting a key

Start by creating a prepaid wallet on Coasty, then generate a key in the developer portal. Use that key as X-API-Key or Authorization: Bearer in your requests. For more detailed examples and integrations, visit the Coasty developer docs. Get your key at https://coasty.ai/developers and start building self-running QA bots with the computer use API today.

Want to see this in action?

View Case Studies
Try Coasty Free