A computer-use agent reads a screenshot or accessibility tree, chooses a mouse or keyboard action and repeats until the goal is met. That lets it operate apps and websites that have no API. Examples are Anthropic Computer Use, OpenAI's Operator (built on its computer-using agent model), Google Project Mariner and the open-source Browser-Use.
The observe, act, verify loop
The agent runs one loop per step. A multimodal model looks at the current GUI state, decides on the next action and returns either coordinates or a reference to a DOM element. An executor then performs the action in a controlled browser, usually inside a sandbox, often driven through a library such as Playwright.
- Capture the screen, or read the accessibility tree of the application.
- Ask the model to plan the next click or keystroke from that state.
- Execute the action in the sandboxed browser.
- Take a new screenshot to check the result.
- Repeat until the goal is reached or a human is asked to confirm.
Take a form on a legacy web application. The agent captures the page, identifies the fields from their labels and positions in the accessibility tree, plans the inputs and fills them in. If the layout shifts, it re-reads the page and finds the fields again.
DOM grounding versus pixel coordinates
An action can be anchored to a pixel position or to an element in the DOM or accessibility tree. Pixel clicks break when the layout moves a little and land on the wrong element. Grounding on the DOM structure is faster and more stable, because the agent looks the element up again each step instead of trusting a stored position.
Selenium and Playwright scripts are the closest relative. Those scripts fix their selectors in advance and break when the page changes. A computer-use agent chooses actions from the current page and the goal, so it tolerates small UI changes. The price is speed: each step waits on a model call, and a scripted test runs faster and more predictably.
Injected page text and the sandbox around the agent
The agent reads whatever the page shows, so text injected into a page can mislead it into actions nobody intended. Scripted test automation has much less of this exposure, because it does not read the page to decide what to do. Four controls limit the damage:
- Run the browser in a confined container that can reach allowlisted domains only.
- Give the agent least-privilege credentials.
- Require human confirmation for irreversible actions.
- Add content-injection defenses on what the agent reads.
Prompt injection is a serious risk for this class of agent, and these controls reduce it without removing it.
Choosing between an API, an MCP tool and a browser agent
Scraping a system without an API tends to be unreliable and can break the provider's terms of service. Manual operation is slow and error-prone. A browser agent covers the gap for older internal applications and third-party portals.
| Option | Use when | Trade-off |
|---|---|---|
| API or MCP tool | One exists | Faster, cheaper and safer than driving a GUI |
| Browser agent | The system has no API | Latency from the feedback loop, plus injection risk |
| Scraping or manual work | Rarely | Fragile, may breach terms of service, slow |
Example scenario: click failures after a UI change
Example scenario: an agent starts missing 30% of its button clicks after the target web application ships a UI update. The DOM structure or CSS has changed, and the agent now misidentifies elements it used to find.
- Read the browser console for JavaScript errors during the failing interactions.
- Log each attempted interaction and compare it with the expected element identifiers such as IDs and classes.
- Run a visual regression tool to compare the current UI with the one the agent was built against.
The fix is to update how the agent identifies elements so it matches the new structure. Watch the task completion rate closely for the following week.