Browser use automation

From ahang1598/doubao-workbuddy-qwenwork-skills · View interactive version

Browser use automation is an AI agent skill from the GitHub repository ahang1598/doubao-workbuddy-qwenwork-skills. Control websites through the Aha Browser Use backend with `computer_use_tool`, `plane="bu"`, and `aha_browser_use`. Use whenever the user asks to open or navigate a web page, inspect visible content or UI state, click, type, select, upload or download files, take screenshots, manage tabs, test a web

How to use this skill

Skill file

Browser Use Automation

Inspect and interact with live websites through the attached Aha Browser Use session.

Implementation boundary

Choose the correct surface

The Browser Use daemon are already installed and attached. Do not launch, restart.

computer_use_tool(plane="bu", code="...", title="Inspect the pricing page")

Inside the browser cell:

import aha_browser_use as bu

bu.navigate("https://example.com")
bu.wait_for_load()
print(bu.snapshot())
# or print(bu.extract_content())

The declared plane must match the library used by the cell. Move standalone filesystem, parsing, or shell work to its appropriate tool.

Route specialized website tasks

Read only the references needed for the current task:

The site references refine this executor; they do not replace the ref-first Browser Use rules below.

Safety and trust boundary

Mandatory user handoff and authorization

Login and verification checkpoints

Treat the current page as authentication-blocked when, and only when, the user-requested content or action cannot be reached without getting past a login or verification step:

Decide by content-availability, not by the presence of a login control. The literal blocked=auth marker is sufficient but not required. A passive login or sign-up button is not by itself a blocker: when the user-requested content and actions are already readable and usable with the login UI left in place, keep working and do not hand off. Confirm availability with a non-destructive read (bu.get_page_text(), bu.extract_content(), or bu.read_all()) that leaves any login or verification UI untouched — never close or dismiss that UI to find out whether the content is reachable. If the read returns the requested content, it is passive; if it returns empty, a login prompt, or only a truncated preview, it is a blocker and the next tool call must be interaction.request_action. That blocked read settles it for this site: do not first probe a different URL, entry point, mobile or app surface, cached copy, or an external search engine hoping to reach the same content without logging in — those attempts are exactly the fallback this ordering rule overrides, so hand off before trying any of them. An empty read with no login signal is not this case — treat it as a normal no-result, an unloaded lazy list, or a transient error, and diagnose it the usual way rather than handing off.

Once an authentication blocker is detected, the very next tool call must be interaction.request_action with type="browserControl". This ordering rule takes precedence over research breadth, source-count goals, recovery attempts, and fallback planning.

Example:

{
  "type": "browserControl",
  "display_message": "当前微博页面需要登录或验证码。请接管浏览器完成页面上的验证,完成后把控制权交回;我会重新读取页面并继续。"
}

Other handoff cases

Use interaction.request_action when the next step must be performed or explicitly authorized by the user, including:

For non-login browser control:

{
  "type": "browserControl",
  "display_message": "请接管浏览器检查这条微博的账号、正文和可见范围,并选择发布或取消。完成后把控制权交回,我会验证最终状态。"
}

For file selection or upload:

{
  "type": "fileUpload",
  "display_message": "请在当前页面选择并上传要发布的图片。上传完成后把控制权交回,我会检查预览并继续。"
}

In display_message, state the site, exact requested action, why user intervention is needed, and the resume condition. Call the tool only when the action is ready; do not request broad advance authorization. After control returns, take a fresh observation and verify the state instead of assuming completion. If the user declines or the checkpoint remains unresolved, stop that branch without claiming success.

Default observe-acts-observe loop

  1. Navigate to the target page or select the intended tab if necessary.
  2. Observe the current state with bu.snapshot(), bu.extract_content(), or a targeted structured read as the task needs.
  3. Perform actions whose targets are grounded in the current observation.
  4. Observe the resulting state to verify the action and prepare for the next step.
  5. Use coordinates, JavaScript, or CDP only if the normal API cannot express the task.

Prefer batch operations as possible to reduce the number of round trips to the browser.

Observation strategy

Use snapshot() for interaction tasks; it returns a str describing page structure and actionable refs.

Use extract_content() for articles, papers, documentation, and other reading tasks; it returns

semantic content in document order without action noise. Pass one type or a short type list when

only specific content matters. When the target region is known,

use snapshot(within=...) with a fresh ref or a CSS locator; this limits the result to that subtree but does not

scroll to it.

Use find() when the target text or intent is already known and refs are needed.

Use get_page_text() to read rendered text from the document or one known region without structure or

action noise.

Use read_all() to read multiple records with structured fields.

NOTE:

# Normal observe: Observe limited important content in viewport.
print(bu.snapshot(within="viewport", view="outline", max_chars=2000))
# To interactive: inspect controls and obtain refs in viewport for the next action.
print(bu.snapshot(within="viewport", view="interactive", max_chars=3000))
# To read content with ref: get all content in viewport.
all_snapshot = bu.snapshot(within="viewport", view="all", max_chars=4000)
print(all_snapshot[3000:4000])

# Known region: observe only one subtree by CSS or a fresh ref.
# Use `within` to get the content out of the viewport.
print(bu.snapshot(within="n42"))
print(bu.snapshot(within=bu.css("main", match="first"), max_chars=3000))
cards = bu.snapshot(within=bu.css("div.card", match="all"), view="all")
# Filter the returned snapshot text.
for line in cards.splitlines():
  if "golf" in line.lower():
    print(line)

# Reading page: extract all "heading", "paragraph", "list", "link", "table" content to Markdown.
article = bu.extract_content(max_chars=8000)
print(str(article)[:3000])

# Focused extraction: consume selected structured blocks in code.
tables = bu.extract_content(types=["table"], within=bu.css("table.tablename", match="all"))
print(tables)

# Repeated known regions: one flat block list, grouped by scope_index when needed.
sections = bu.extract_content(
    types=["heading", "paragraph"], # "heading", "paragraph", "list", "link", "table" or "all"
    within=bu.css("article", match="all"),
)
matched = [block for block in sections if "target phrase" in str(block).lower()]
print("\n".join(str(block) for block in matched[:25]))

# Reading page: extract all content to plain text.
print(bu.get_page_text(max_chars=6000))
# Known region: extract all content within a known region.
print(bu.get_page_text(within="n42", max_chars=6000))
print(bu.get_page_text(within=bu.css("table.tablename", match="all"), max_chars=6000))
main_text = bu.get_page_text(
    within=bu.css("main", match="first"),
    max_chars=6000,
)
print(main_text[2000:3000])

# Find Checkout to interact with.
matches = bu.find("Checkout", search_type="interaction", limit=5)
print(matches) # Print the matches to observe the search results.
# Or filter the matches.
if matches.first:
    label = bu.text(matches.first)
    href = bu.get(matches.first, "href")
    css_locators = bu.get_css_locator(matches.first)

# Find golf or red polo to read or interact with.
contents = bu.find("golf|polo&red", search_type="all", limit=5)
print(contents)

rows = bu.read_all(
    "table tbody tr",
    fields=["text", "href"],
    limit=50,
)
# rows:
#[{
#  "ref": "n299",
#  "text": "fool",
#  "href": "bar",
#},]
print(rows)

rows = bu.read_all(
    "article",
    fields={
      "title": {"selector": "h2, h3", "field": "text"},
      "form_select": {"selector": "form select", "field": "value", "limit": 2},
    },
    limit=20,
)
print(rows)

Observation API reference

When a task needs page observation, read references/observation-api.md

before choosing API parameters or processing structured results. It is the source of truth for

the observation selection matrix, signatures, return shapes, truncation semantics, and ref/CSS

conversion. The examples above cover the common interaction, reading, filtered extraction, and

targeted structured-read workflows.

Page-provided WebMCP tools

The first time a snapshot shows @hint webmcp on a given page, you must first call bu.webmcp_tools() to inspect the WebMCP tools; reuse that list on the same page, and call it again when the hint's tool count changes or the page navigates. Whenever a page-provided tool supports the current task, prioritize it over other page-interaction methods; they are usually more accurate and faster. Inspect the selected tool's full inputSchema before calling it.

for tool in bu.webmcp_tools():
    print(tool)

# Example result:
# {
#   'name': 'focus_state',
#   'description': 'Read page focus and editor state without changing either.',
#   'inputSchema': {
#     'type': 'object',
#     'properties': {'echo': {'type': 'string'}},
#     'required': ['echo']
#   },
#   'annotations': {'readOnly': True}
# }
print(bu.webmcp_call("focus_state", {"echo": "check current focus"}))

Tool names and schemas are page-specific. Observe the page again when needed to verify results or continue interacting. Existing authorization rules also apply to WebMCP calls.

Native node refs

A printed snapshot contains refs tied to the current document:

@page scope=d7 view=interactive within=viewport total_nodes=18 shown=18/18 title="Sign in" url=https://example.com/login viewport=1280x720
n15 textbox "Name" [type=input_text]
n16 textbox "Email" [type=input_email]
n17 button "Sign in"

Pass the complete ref back exactly:

bu.type("n15", "aha", submit=False) # Type "aha" into the Name textbox.
bu.type("n16", "me@example.com", submit=True) # Type "me@example.com" into the Email textbox and submit.

bu.make_ref("n15") validates and wraps a Native node ID.

Use the nN ref directly for ref-first actions. Navigation,

reload, document replacement, or closing a tab invalidates observed node IDs; Native rejects IDs

that are absent from the current locator registry, so take a fresh observation.

bu.find("Save") returns exact-first ranked match refs and supports .first. Its ref-bearing parent

and preceding-sibling lines provide local structure for distinguishing repeated labels. If several

matches remain plausible, narrow the query or inspect the relevant region.

CSS locator

A CSS locator is a selector rule that Native resolves against the current DOM when the read or

action runs:

checkout = bu.css("#checkout", match="unique")  # match="unique" by default
bu.click(checkout)
bu.snapshot(within=bu.css("main", match="first"))
cards = bu.read_all(
    bu.css("article.product", match="all"),
    fields=["text"],
    limit=20,
)

Use unique when exactly one target is expected, first when document order is intentional, and

all for multi-result queries or reads. Single-target actions accept

unique or first, and scoped observations accept all.

Use bu.get_css_locator(ref) to generate reusable locators from a ref; its .first is the primary

locator(exlicit single match) or None. See

Observation API Reference for parameters and

return shapes.

Interact with page elements

Use refs or css locators for normal interactions, but prefer refs:

ref = "n16"
locator = bu.css('input[type="email"]', match="first")
target = ref or locator  # Prefer ref if known.
bu.click(target)
bu.click(target, clicks=2)
bu.hover(target)
bu.scroll(target, direction="down", amount=3)
bu.scroll_into_view(target)
bu.type(target, "hello", submit=False) # Replace the current value.
bu.type(target, "hello", submit=True) # Input and submit form.
bu.type(target, " more", replace=False) # Append to the current value.
bu.select(target, "Germany") # For select drop-down list.
bu.upload_file('input[type="file"]', absolute_path)

Setting submit=True presses Enter after typing to trigger search or form submission. Offscreen inputs remain eligible.

After each interaction, inspect the cheapest authoritative signal: a fresh snapshot, selected state, success message, changed URL, modal, or relevant page fragment.

Navigation and tabs

bu.navigate("https://example.com")
bu.navigate("back")
bu.navigate("forward")
bu.navigate("reload")

tab = bu.new_tab("https://example.org")
target = next(t for t in bu.list_tabs() if "example.org" in t["url"])
bu.switch_tab(target)
print(bu.current_tab())
bu.close_tab()

Handle tabs sequentially: switch, observe, then act. When a click, link, or popup lands the task in another tab, pick it by matching url/title in a fresh bu.list_tabs() rather than a remembered index, then bu.switch_tab(target), which attaches to that tab and raises it to the front. If nothing matches, bu.resync() back to the on-screen tab and re-observe instead of guessing an index. Never reuse refs from a previous or replaced document. After BU_SESSION_STALE — or after the user or desktop moved the on-screen tab out from under bu — call bu.resync() to re-attach to the visible tab, then observe again.

Wait page stability

Prefer use wait_for_load() and wait_for_element() to wait for page stability after navigation or interaction.

Avoid frequent time.sleep().

bu.wait_for_load(timeout=5)
bu.wait_for_element("#result", visible=True)

Screenshots and coordinates

frame = bu.screenshot()
field = bu.screenshot(ref="n16", tag="email-field")
clean_frame = bu.screenshot(path="saved-page.png", with_cursor=False)
print(frame.path, frame.width, frame.height)

A normal screenshot covers the viewport and includes the latest virtual Browser Use pointer by default so the model can ground the last interaction and normalized viewport coordinates. When the user explicitly asks to save, export, or receive a screenshot or rendered image, call bu.screenshot(..., with_cursor=False) so the delivered image is clean. A ref crop is evidence about that element only and must not be used to infer viewport coordinates.

Match the evidence to the deliverable. Read facts through DOM and structured reads, not screenshot OCR. When the deliverable is an embedded image or file, capture the resource itself with bu.download(), or the rendered element with bu.screenshot(ref=..., with_cursor=False); never present a plain viewport screenshot as that asset. For a relevant visual outside the viewport, scroll first and take a fresh screenshot — do not reuse coordinates from before a scroll, navigation, or layout change.

Use coordinate actions only for canvas, WebGL, or interfaces with no usable DOM target:

bu.click_xy(500, 400)
bu.left_double(500, 400)
bu.right_single(500, 400)
bu.drag(200, 400, 800, 400)
bu.scroll(x=500, y=500, direction="down", amount=3)
bu.hotkey("ctrl", "a")
bu.press_key("Enter")

bu.click_xy, bu.drag, and bu.scroll(x=..., y=..., ...) use coordinates relative to the page viewport, normalized to a 0-1000 range.

Downloads

For a direct HTTP(S) link or URL:

record = bu.download("n20")
record = bu.download(
    "https://example.com/report.csv",
    filename="report.csv",
    timeout=30,
)
print(record["path"], record["filename"], record["bytes"])

For a browser-triggered download:

bu.click(download_button_ref)
record = bu.wait_for_download(timeout=30)
print(record)

Only completed downloads expose a final path. Never report .crdownload or another partial file as complete.

Dialogs, uploads, and diagnostics

bu.click_and_handle_dialog(ref, accept=True)
bu.handle_dialog(accept=False)
bu.upload_file(selector, absolute_path)

print(bu.console_messages())
print(bu.network_requests())
print(bu.http_get("https://example.com/data.json"))

Console and network reads drain only their own buffered events. http_get() returns decoded text; it does not prove that the rendered page changed. If the user must choose the file, use interaction.request_action with type="fileUpload" instead of guessing a local path.

JavaScript and CDP fallbacks

Use bu.js() or raw bu.cdp() only when a supported ref-first, structured-read, screenshot, or coordinate action cannot express the task. Keep the fallback read-only when possible, scope it narrowly, and return to the normal observe-act-observe loop afterward.

Do not use JS or CDP to inspect protected browser state, bypass authentication, suppress safety interstitials, or evade required user confirmation.

Recover from stable failures

| Failure | Recovery |

|---|---|

| BU_REF_SHAPE | Use a complete nN ref from the latest snapshot or find() result. |

| BU_REF_STALE | Re-observe the current document and choose a fresh ref. |

| BU_SESSION_STALE | Run bu.resync(), then observe again. |

| BU_NAV_WAIT_TIMEOUT | Inspect page_info() or a snapshot before deciding whether to retry. |

| BU_SELECT_AMBIGUOUS | Inspect the available options and choose one exact ref. |

| BU_READ_FIELDS / BU_READ_TARGET | Correct the structured read shape or target. |

| BU_READ_LIMIT / BU_EXPORT_LIMIT | Pass an integer budget; numeric values outside the range are already clamped. |

| BU_DOWNLOAD_BLOCKED / BU_DOWNLOAD_TIMEOUT | Report the failure; do not claim a partial file. |

| blocked=auth, login page, or verification challenge | Call interaction.request_action with type="browserControl"; after handoff, re-observe with fresh refs. |

If an action appears to have no effect, inspect the current page for a blocker or changed state before retrying. Do not blindly repeat the same action or immediately fall back to coordinates.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.