Tutorial

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

Sophia Martinez||12 min
Ctrl+S

QA teams struggle with flaky selectors and brittle page objects. End-to-end tests break when UI changes. A computer use API agent solves this by seeing the application like a human and acting on it. You can provision a cloud machine, drive it with a real-time agent, and run full QA scenarios without hard-coding selectors. This tutorial builds a self-running QA bot that logs in, navigates, and asserts on a real browser.

How it works

The QA bot uses three core Coasty endpoints. First, POST /v1/machines provisions a cloud VM. The agent runs on this real desktop. Second, POST /v1/runs starts a task run with a task description, optional instructions, and cua_version "v4" for autonomous mode with a pass/fail verifier. The agent captures screenshots, predicts actions, and executes them until the run succeeds or fails. Third, GET /v1/runs/{id}/events streams events in real time so you can show progress. Billing is $0.05 per agent step.

bash
# 1. Provision a cloud machine (Linux, macOS, or Windows)
export COASTY_API_KEY="your-api-key-here"

# POST /v1/machines creates a cloud VM
MACHINE=$(curl -s -X POST https://coasty.ai/v1/machines \
  -H "X-API-Key: $COASTY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "os": "linux",
    "size": "medium"
  }')

# Extract the machine_id from the response
MACHINE_ID=$(echo $MACHINE | jq -r '.machine_id')
echo "Machine provisioned: $MACHINE_ID"

# 2. Start a QA task run on that machine
# POST /v1/runs drives the agent to completion
RUN=$(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. Log in with user [email protected] and pass Test123!. Navigate to /login and verify the page title contains 'Login'.",
    "cua_version": "v4",
    "on_awaiting_human": "pause",
    "max_steps": 100,
    "deadline_seconds": 300
  }')

RUN_ID=$(echo $RUN | jq -r '.run_id')
echo "Run started: $RUN_ID"

# 3. Stream events from the run to see progress
# GET /v1/runs/{id}/events streams Server-Sent Events
curl -s -N -H "X-API-Key: $COASTY_API_KEY" \
  "https://coasty.ai/v1/runs/$RUN_ID/events" \
  --no-buffer | jq -c 'select(.event != "")'

# 4. Get the final run status (optional)
FINAL=$(curl -s -X GET https://coasty.ai/v1/runs/$RUN_ID \
  -H "X-API-Key: $COASTY_API_KEY")
echo "Run status: $(echo $FINAL | jq -r '.status')"

echo "QA bot finished with status: $(echo $FINAL | jq -r '.status')"

Key fields and options

  • machine_id from POST /v1/machines is required for the run.
  • task is a natural language description of the QA scenario.
  • cua_version can be "v3" or "v4". v4 includes a pass/fail verifier.
  • on_awaiting_human can be "pause", "fail", or "cancel" when the agent needs input.
  • max_steps caps how many agent steps the run can take.
  • deadline_seconds stops the run if it exceeds the time limit.
  • Events are streamed through GET /v1/runs/{id}/events for real-time feedback.
  • Billing: $0.05 per agent step; total steps are shown in events.
  • You can cancel or resume a run with POST /v1/runs/{id}/cancel and POST /v1/runs/{id}/resume.

POST /v1/runs with machine_id and a natural language QA task drives an autonomous agent to completion. Billing is $0.05 per agent step.

Where this beats brittle automation

Traditional automation relies on CSS selectors, XPath, or page object models. A change in class names, IDs, or layout breaks tests. The computer use API agent sees the screen, understands context, and clicks or types accordingly. It can handle dynamic elements, hidden fields, and UI changes without selector updates. It also works on desktop apps and terminals, not just browsers. This makes QA tests more resilient and closer to real user behavior.

Next steps

  • Provision a machine with POST /v1/machines from a CI/CD pipeline.
  • Write QA tasks in natural language and include assertions in the task description.
  • Monitor run events with GET /v1/runs/{id}/events and report failures to your team.
  • Use workflows to orchestrate multiple QA scenarios in sequence.
  • Explore MCP integration to control Coasty from Cursor or Claude Desktop.
  • Get an API key at https://coasty.ai/developers and start building a self-running QA bot.

Want to see this in action?

View Case Studies
Try Coasty Free