Tutorial

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

Lisa Chen||8 min
+Tab

Traditional QA bots rely on brittle selectors, API mocks, and brittle XPath. They break when UI changes or layout shifts. The Coasty computer use API lets you build a self-running QA testing bot that sees the screen, reads text, and acts like a human. You drive real browsers and desktops, keep a stateful trajectory in sessions, and orchestrate multi-step test flows with a workflow DSL. This guide shows how to create a bot that logs in, fills a form, and asserts a success message, all from your test script.

How it works

The computer use API works in three layers. First, the API provisions a cloud machine with POST /v1/machines. The agent drives that machine's desktop, browser, or terminal. Second, you run a task on that machine with POST /v1/runs. The run includes a machine_id, task description, and optional instructions. You can also pass a system_prompt, max_steps, deadline_seconds, and a webhook_url for real-time events. Third, you orchestrate complex flows with a workflow DSL via POST /v1/workflows. The workflow DSL supports task, assert, if, loop, parallel, human_approval, retry, succeed, and fail steps, with variables like {{inputs.x}} and stepId.field. Each task step costs $0.05 per agent step. The API streams events to GET /v1/runs/{id}/events using Server-Sent Events, so you can track progress and react to UI states.

bash
# Provision a cloud machine and run a QA test bot

export COASTY_API_KEY="${COASTY_API_KEY}"

# Create a workflow that performs a login and verification
# Save this as a .json file, for example test_workflow.json

# Example workflow (save to test_workflow.json):
# {
#   "name": "login_and_verify",
#   "version": "1",
#   "steps": [
#     { "type": "task", "task": "Open https://example.com/login in the browser" },
#     { "type": "task", "task": "Type the username '{{inputs.username}}' into the username field" },
#     { "type": "task", "task": "Type the password '{{inputs.password}}' into the password field" },
#     { "type": "task", "task": "Click the login button" },
#     { "type": "assert", "expression": "See text 'Welcome back' on the page" },
#     { "type": "succeed" }
#   ]
# }

# Upload the workflow
WORKFLOW_RESPONSE=$(curl -s -X POST https://coasty.ai/v1/workflows \
  -H "X-API-Key: $COASTY_API_KEY" \
  -H "Content-Type: application/json" \
  -d @test_workflow.json)
WORKFLOW_ID=$(echo "$WORKFLOW_RESPONSE" | jq -r '.id')

# Run the workflow with inputs
RUN_RESPONSE=$(curl -s -X POST "https://coasty.ai/v1/workflows/${WORKFLOW_ID}/runs" \
  -H "X-API-Key: $COASTY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "machine_id": "<your-provisioned-machine-id>",
    "inputs": {
      "username": "[email protected]",
      "password": "password123"
    }
  }')
RUN_ID=$(echo "$RUN_RESPONSE" | jq -r '.id')

# Poll for the run status
STATUS=$(curl -s -X GET "https://coasty.ai/v1/runs/${RUN_ID}" \
  -H "X-API-Key: $COASTY_API_KEY" | jq -r '.status')

echo "Run status: $STATUS"

# Stream events for debugging
curl -s -N "https://coasty.ai/v1/runs/${RUN_ID}/events" \
  -H "X-API-Key: $COASTY_API_KEY"

Workflow DSL basics

  • POST /v1/workflows creates a versioned JSON DSL of runs.
  • Step types include task, assert, if, loop, parallel, human_approval, retry, succeed, fail.
  • Variables use double-brace syntax, e.g., {{inputs.username}} or stepId.field.
  • Hard guards: budget_cents, max_iterations, deadline_seconds.
  • Task steps are billed $0.05 each.
  • You can run workflows inline with POST /v1/workflows/runs.

Each task step costs $0.05 per agent step, billed against a prepaid USD wallet.

Where this beats brittle automation

Traditional test bots rely on explicit selectors and API mocks. They break when a button moves, an ID changes, or the layout shifts. The computer use API drives real browsers and desktops, so the bot sees exactly what the user sees. With stateful sessions and trajectory memory, the bot remembers previous actions and UI state across steps. The workflow DSL lets you compose multi-step flows with conditions and retries without hardcoding every click. You can pause for human approval, cancel on failure, and listen to real-time events via Server-Sent Events. This makes your QA bot resilient to UI changes and less prone to maintenance overhead.

You now have the blueprint to build a self-running QA testing bot with the Coasty computer use API. Use POST /v1/machines to provision a cloud machine, POST /v1/workflows to define your test DSL, and POST /v1/runs to execute tasks. Stream events from GET /v1/runs/{id}/events to monitor progress. Each task step is $0.05. To get started, get a key at https://coasty.ai/developers.

Want to see this in action?

View Case Studies
Try Coasty Free