browser-form-fill

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Browser Form Fill

浏览器表单填充

Fill a form using a structured field map (
{"first_name": "Ada", "company": "..."}
). When a
browser-templates
entry exists for the host, use it to resolve field names → CSS selectors automatically; otherwise resolve via the page accessibility snapshot.
通过结构化字段映射(
{"first_name": "Ada", "company": "..."}
)填充表单。如果针对当前主机存在
browser-templates
条目,则自动使用其解析字段名称→CSS选择器;否则通过页面可访问性快照进行解析。

When to use

使用场景

  • Submitting a known form (signup, contact, checkout) where field names are stable.
  • Re-using a stored template for a recurring submission.
  • Authoring a new template for a site by recording the resolved selectors.
  • 提交已知表单(注册、联系、结账),且字段名称稳定时。
  • 为重复提交复用已存储的模板。
  • 通过记录解析后的选择器为网站创建新模板。

Steps

操作步骤

  1. Open a recorded session via
    browser-record
    .
  2. Resolve selectors:
    • Template path (
      --template <name>
      ): pull
      {field_name → selector}
      from
      browser-templates
      .
    • Snapshot path: call
      browser_snapshot
      , walk the accessibility tree, match each input's accessible name / label to the field map keys.
  3. AIDefence PII gate: every value in the field map passes
    aidefence_has_pii
    before any keystroke; record
    pii_in_form: true
    in the session manifest. Do not record the values themselves in the trajectory; record only the field names + a redacted placeholder.
  4. Fill with
    browser_fill
    /
    browser_type
    /
    browser_select
    /
    browser_check
    per input type.
  5. Submit if
    --submit
    : locate the submit button via the snapshot,
    browser_click
    , then
    browser_wait
    for navigation.
  6. Persist the template if a new mapping was discovered:
    bash
    npx -y @claude-flow/cli@latest memory store --namespace browser-templates \
      --key "<host>:<form-name>" \
      --value "{field_map:{...}, submit_selector:..., post_submit_url_pattern:...}"
  7. Verify post-submit state if a verification snippet was provided in the field map's
    _assert
    key.
  1. 通过
    browser-record
    打开录制会话
  2. 解析选择器:
    • 模板路径
      --template <name>
      ):从
      browser-templates
      中提取
      {字段名称→选择器}
      映射。
    • 快照路径:调用
      browser_snapshot
      ,遍历可访问性树,将每个输入框的可访问名称/标签与字段映射的键进行匹配。
  3. AIDefence PII网关:在输入任何按键之前,字段映射中的每个值都会经过
    aidefence_has_pii
    检查;在会话清单中记录
    pii_in_form: true
    请勿在轨迹中记录值本身,仅记录字段名称+脱敏占位符。
  4. 根据输入类型填充:使用
    browser_fill
    /
    browser_type
    /
    browser_select
    /
    browser_check
    进行填充。
  5. 若指定
    --submit
    则提交
    :通过快照定位提交按钮,调用
    browser_click
    ,然后
    browser_wait
    等待页面导航。
  6. 若发现新映射则保存模板:
    bash
    npx -y @claude-flow/cli@latest memory store --namespace browser-templates \
      --key "<host>:<form-name>" \
      --value "{field_map:{...}, submit_selector:..., post_submit_url_pattern:...}"
  7. 若字段映射的
    _assert
    键中提供了验证代码段,则验证提交后的状态

Caveats

注意事项

  • Trajectory steps for fills MUST redact values. The PII gate is the contract.
  • For inputs that require typing simulation (e.g., autocomplete reactions), use
    browser_type
    (simulates keystrokes) rather than
    browser_fill
    (sets value programmatically). Record which one was used in the trajectory step.
  • Multi-step forms are a sequence of
    browser-form-fill
    invocations; chain them via the same session id.
  • If the form has a CAPTCHA, surface the request to the user — do not attempt to bypass.
  • 填充操作的轨迹步骤必须对值进行脱敏。PII网关是核心约束。
  • 对于需要模拟输入的输入框(如自动补全响应),请使用
    browser_type
    (模拟按键输入)而非
    browser_fill
    (通过编程方式设置值)。在轨迹步骤中记录使用的方法。
  • 多步骤表单需通过多次调用
    browser-form-fill
    完成;通过同一个会话ID将它们串联起来。
  • 若表单包含CAPTCHA,请将请求提交给用户处理——请勿尝试绕过。