browser-automation

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

What I do

核心功能

  • Provide a safe, composable workflow for browsing tasks
  • Use
    browser_query
    list and index selection to click reliably
  • Confirm state changes after each action
  • 为浏览任务提供安全、可组合的工作流
  • 使用
    browser_query
    的列表与索引选择实现可靠点击
  • 在每个操作后确认状态变更

Best-practice workflow

最佳实践工作流

  1. Inspect tabs with
    browser_get_tabs
  2. Open new tabs with
    browser_open_tab
    when needed
  3. Navigate with
    browser_navigate
    if needed
  4. Wait for UI using
    browser_query
    with
    timeoutMs
  5. Discover candidates using
    browser_query
    with
    mode=list
  6. Click, type, or select using
    index
  7. Confirm using
    browser_query
    or
    browser_snapshot
  1. 使用
    browser_get_tabs
    检查标签页
  2. 必要时使用
    browser_open_tab
    打开新标签页
  3. 必要时使用
    browser_navigate
    进行导航
  4. 结合
    timeoutMs
    参数使用
    browser_query
    等待UI加载
  5. 使用
    mode=list
    browser_query
    发现候选元素
  6. 通过
    index
    参数执行点击、输入或选择操作
  7. 使用
    browser_query
    browser_snapshot
    确认操作结果

Selecting options

选项选择操作

  • Use
    browser_select
    for native
    <select>
    elements
  • Prefer
    value
    or
    label
    ; use
    optionIndex
    when needed
  • Example:
    browser_select({ selector: "select", value: "plugin" })
  • 针对原生
    <select>
    元素使用
    browser_select
  • 优先使用
    value
    label
    参数;必要时使用
    optionIndex
  • 示例:
    browser_select({ selector: "select", value: "plugin" })

Query modes

查询模式

  • text
    : read visible text from a matched element
  • value
    : read input values
  • list
    : list many matches with text/metadata
  • exists
    : check presence and count
  • page_text
    : extract visible page text
  • text
    :从匹配元素中读取可见文本
  • value
    :读取输入框的值
  • list
    :列出所有匹配元素及其文本/元数据
  • exists
    :检查元素是否存在及数量
  • page_text
    :提取页面可见文本

Opening tabs

标签页打开操作

  • Use
    browser_open_tab
    to create a new tab, optionally with
    url
    and
    active
  • Example:
    browser_open_tab({ url: "https://example.com", active: false })
  • 使用
    browser_open_tab
    创建新标签页,可选择性传入
    url
    active
    参数
  • 示例:
    browser_open_tab({ url: "https://example.com", active: false })

Troubleshooting

故障排查

  • If a selector fails, run
    browser_query
    with
    mode=page_text
    to confirm the content exists
  • Use
    mode=list
    on broad selectors (
    button
    ,
    a
    ,
    *[role="button"]
    ) and choose by index
  • Confirm results after each action
  • 如果选择器失效,使用
    mode=page_text
    browser_query
    确认内容是否存在
  • 对宽泛选择器(如
    button
    a
    *[role="button"]
    )使用
    mode=list
    ,并通过索引选择元素
  • 在每个操作后确认结果