Back to Blog
Tutorial

Daniel Kim7 min
Ctrl+S

Modern QA needs more than brittle selectors and API mocks. You want an end-to-end test that actually opens a browser, clicks a button, fills a form, and sees the result. The Coasty Computer Use API gives you a self-running QA bot that watches your screen and acts like a human. It drives real browsers, desktop apps, and terminals and bills $0.05 per agent step. No selectors to maintain, no fragile XPath, and no fragile headless browser hacks.

How the Computer Use API Drives a QA Test

A QA test with the Computer Use API is a sequence of captures, predictions, and actions. You start a machine, send a task that describes the steps, and let the agent run until the test succeeds, fails, or needs human approval. The server handles vision, state, and step billing. Here is the flow in detail.

  • POST /v1/machines provisions a cloud VM where you run a browser, desktop app, or terminal.
  • POST /v1/runs submits a task with machine_id, task, cua_version (v3 or v4), and optional instructions.
  • The server runs the agent step by step, capturing screenshots, predicting actions, and billing $0.05 per step.
  • GET /v1/runs/{id}/events streams events so you can watch progress and handle awaiting_human states.
  • States you can act on: queued, running, awaiting_human, succeeded, failed, cancelled, timed_out.
bash
install dependencies
pip install requests python-dotenv

copy .env and add COASTY_API_KEY=your_key_here

run the QA bot
python qa_bot.py
python
import os
import json
import requests
from dotenv import load_dotenv

def run_qa_test():
    load_dotenv()
    api_key = os.getenv("COASTY_API_KEY")
    url = "https://coasty.ai/v1"

    # 1. Provision a machine (cloud VM)
    machines_url = f"{url}/machines"
    headers = {"X-API-Key": api_key}
    resp = requests.post(
        machines_url,
        json={"name": "qa-test-machine", "cpu": 2, "memory_gb": 8},
        headers=headers,
    )
    resp.raise_for_status()
    machine = resp.json()
    machine_id = machine["id"]
    print("Provisioned machine", machine_id)

    # 2. Run a QA task on that machine
    runs_url = f"{url}/runs"
    task = "Open https://coasty.ai in Firefox and verify the title contains 'Coasty'."
    body = {
        "machine_id": machine_id,
        "task": task,
        "cua_version": "v3",
        "max_steps": 50,
        "deadline_seconds": 300,
        "on_awaiting_human": "pause",
    }
    resp = requests.post(runs_url, json=body, headers=headers)
    resp.raise_for_status()
    run = resp.json()
    run_id = run["id"]
    print("Run started", run_id)

    # 3. Poll for events until done or awaiting human
    events_url = f"{url}/runs/{run_id}/events"
    while True:
        resp = requests.get(events_url, headers=headers)
        resp.raise_for_status()
        events = resp.json()
        for event in events:
            print(event)
            if event.get("state") in ("succeeded", "failed", "cancelled", "timed_out"):
                break
        if any(e.get("state") in ("succeeded", "failed", "cancelled", "timed_out") for e in events):
            break

    print("Run ended", run_id)
    # Optionally cancel if you want to stop the machine
    # requests.post(f"{url}/runs/{run_id}/cancel", headers=headers)

if __name__ == "__main__":
    run_qa_test()

Key QA Test Options You Can Configure

  • cua_version: v3 for guided steps, v4 for an autonomous agent with a pass/fail verifier.
  • max_steps: cap the number of steps to avoid runaway QA tests (e.g., 50 or 100).
  • deadline_seconds: stop a test if it takes too long (e.g., 5 minutes).
  • on_awaiting_human: pause the QA run (pause), fail it (fail), or cancel it (cancel).
  • webhook_url: send a POST when the run reaches final states so your CI/CD can react.

The QA bot bills $0.05 per agent step, so cap max_steps and set deadline_seconds to keep QA runs predictable.

Where This Beats Brittle Automation

Traditional UI tests rely on stable selectors and headless browser hacks. When a layout changes or a framework injects IDs, your test breaks. The Computer Use API works by seeing the screen and acting like a human: it looks at the rendered DOM, finds the button visually, and clicks. This means you can test real user journeys, handle dynamic content, and support multiple browsers without maintaining brittle selectors. You also get robust end-to-end verification, not just API-level assertions.

Your QA bot is now a self-running agent that sees screens and drives browsers and apps like a human. Extend it with workflow steps to parallelize tests, retry on flakiness, or trigger human approval for sensitive actions. Get your API key at https://coasty.ai/developers and build a QA bot that actually works the way users do.

© 2026 Coasty

Backed byYCombinator