Compare commits
7
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f9cc31d003 | ||
|
|
a7a3f924b0 | ||
|
|
7572c34229 | ||
|
|
06f5f9e8f1 | ||
|
|
5f50ca075c | ||
|
|
e7548c3eb5 | ||
|
|
b77a1e4568 |
@@ -139,6 +139,7 @@ When using `--launch` mode (standalone browser), a full suite of 32 stealth patc
|
||||
| `AGENT_BROWSER_BLOCK_WEBRTC` | auto | `--launch` only. Auto-forces WebRTC through the proxy when one is set (no real-IP leak). `1` hides the local IP without a proxy; `0` opts out. |
|
||||
| `AGENT_BROWSER_HIDE_CANVAS` | off | `--launch` only. Adds session-stable canvas/audio fingerprint noise. Off by default (noise is itself a "lie"). |
|
||||
| `AGENT_BROWSER_ADAPTIVE_REF` | on | When a saved `@ref` moves and the role/name re-query fails, relocate it by fingerprint similarity (high score + clear margin required, else it fails loudly). `0` disables. |
|
||||
| `AGENT_BROWSER_CLICK_MODE` | _(auto)_ | Click strategy. Default scrolls the target into view, dispatches a coordinate click, and falls back to a DOM `.click()` if a floating layer occludes the point. `dom` always uses `.click()` (best for autocomplete/menu items that close on blur); `coord` is strict coordinate-only (hard-fail on occlusion). |
|
||||
|
||||
## Differences from upstream
|
||||
|
||||
|
||||
Generated
+1
-1
@@ -45,7 +45,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "agent-browser-stealth"
|
||||
version = "0.27.0-fork.15"
|
||||
version = "0.27.0-fork.17"
|
||||
dependencies = [
|
||||
"aes-gcm",
|
||||
"async-trait",
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "agent-browser-stealth"
|
||||
version = "0.27.0-fork.15"
|
||||
version = "0.27.0-fork.17"
|
||||
edition = "2021"
|
||||
description = "Fast browser automation CLI for AI agents"
|
||||
license = "Apache-2.0"
|
||||
|
||||
@@ -0,0 +1,244 @@
|
||||
//! `find-url` — search the user's local Chrome/Edge **bookmarks** for pages they
|
||||
//! saved, by keyword. Borrowed from web-access's `find-url.mjs`; lets an agent
|
||||
//! locate an internal system or a previously-saved page that public search
|
||||
//! can't reach, without opening a browser.
|
||||
//!
|
||||
//! v1 covers bookmarks only (a zero-dependency JSON read). Visited-history lives
|
||||
//! in a locked SQLite DB and would need a SQLite dependency — not included yet.
|
||||
|
||||
use std::path::PathBuf;
|
||||
|
||||
use serde_json::Value;
|
||||
|
||||
use crate::color;
|
||||
|
||||
struct Hit {
|
||||
name: String,
|
||||
url: String,
|
||||
folder: String,
|
||||
date_added: i64,
|
||||
}
|
||||
|
||||
/// Entry point for the `find-url` subcommand. `args` is the full cleaned argv
|
||||
/// (including the leading "find-url").
|
||||
pub fn run_find_url(args: &[String], json: bool) {
|
||||
// Parse flags out of args[1..]; everything else is a keyword.
|
||||
let mut browser = "chrome".to_string();
|
||||
let mut profile = "Default".to_string();
|
||||
let mut limit: usize = 20;
|
||||
let mut keywords: Vec<String> = Vec::new();
|
||||
|
||||
let mut i = 1;
|
||||
while i < args.len() {
|
||||
match args[i].as_str() {
|
||||
"--browser" => {
|
||||
if let Some(v) = args.get(i + 1) {
|
||||
browser = v.to_lowercase();
|
||||
i += 1;
|
||||
}
|
||||
}
|
||||
"--profile" => {
|
||||
if let Some(v) = args.get(i + 1) {
|
||||
profile = v.clone();
|
||||
i += 1;
|
||||
}
|
||||
}
|
||||
"--limit" => {
|
||||
if let Some(v) = args.get(i + 1).and_then(|s| s.parse::<usize>().ok()) {
|
||||
limit = v;
|
||||
i += 1;
|
||||
}
|
||||
}
|
||||
"--json" => {}
|
||||
other if other.starts_with("--") => {}
|
||||
other => keywords.push(other.to_lowercase()),
|
||||
}
|
||||
i += 1;
|
||||
}
|
||||
|
||||
let path = match bookmarks_path(&browser, &profile) {
|
||||
Some(p) => p,
|
||||
None => {
|
||||
emit_error(
|
||||
json,
|
||||
&format!("Could not locate {browser} bookmarks for profile '{profile}'"),
|
||||
);
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
let raw = match std::fs::read_to_string(&path) {
|
||||
Ok(r) => r,
|
||||
Err(e) => {
|
||||
emit_error(json, &format!("Failed to read {}: {e}", path.display()));
|
||||
return;
|
||||
}
|
||||
};
|
||||
let root: Value = match serde_json::from_str(&raw) {
|
||||
Ok(v) => v,
|
||||
Err(e) => {
|
||||
emit_error(json, &format!("Failed to parse bookmarks JSON: {e}"));
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
let mut hits: Vec<Hit> = Vec::new();
|
||||
if let Some(roots) = root.get("roots").and_then(|r| r.as_object()) {
|
||||
for node in roots.values() {
|
||||
walk(node, "", &keywords, &mut hits);
|
||||
}
|
||||
}
|
||||
|
||||
// Most-recently-added first (date_added is microseconds since 1601).
|
||||
hits.sort_by(|a, b| b.date_added.cmp(&a.date_added));
|
||||
hits.truncate(limit);
|
||||
|
||||
if json {
|
||||
let arr: Vec<Value> = hits
|
||||
.iter()
|
||||
.map(|h| {
|
||||
serde_json::json!({
|
||||
"name": h.name,
|
||||
"url": h.url,
|
||||
"folder": h.folder,
|
||||
})
|
||||
})
|
||||
.collect();
|
||||
println!(
|
||||
"{}",
|
||||
serde_json::to_string(&serde_json::json!({
|
||||
"success": true,
|
||||
"data": { "results": arr, "count": hits.len() },
|
||||
}))
|
||||
.unwrap_or_default()
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
if hits.is_empty() {
|
||||
let kw = if keywords.is_empty() {
|
||||
String::new()
|
||||
} else {
|
||||
format!(" matching {:?}", keywords.join(" "))
|
||||
};
|
||||
println!("No {browser} bookmarks found{kw}.");
|
||||
return;
|
||||
}
|
||||
for h in &hits {
|
||||
if h.folder.is_empty() {
|
||||
println!("{}\n {}", h.name, h.url);
|
||||
} else {
|
||||
println!("{} ({})\n {}", h.name, h.folder, h.url);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Recursively walk a bookmark node, collecting URL entries that match every
|
||||
/// keyword (in name or url). Empty keyword list matches everything.
|
||||
fn walk(node: &Value, folder: &str, keywords: &[String], out: &mut Vec<Hit>) {
|
||||
match node.get("type").and_then(|t| t.as_str()) {
|
||||
Some("url") => {
|
||||
let name = node.get("name").and_then(|v| v.as_str()).unwrap_or("");
|
||||
let url = node.get("url").and_then(|v| v.as_str()).unwrap_or("");
|
||||
// Skip non-navigable bookmarks: javascript: bookmarklets and data:
|
||||
// URIs aren't pages you can visit, and their bodies can be huge.
|
||||
if url.is_empty()
|
||||
|| url.starts_with("javascript:")
|
||||
|| url.starts_with("data:")
|
||||
{
|
||||
return;
|
||||
}
|
||||
let hay = format!("{} {}", name.to_lowercase(), url.to_lowercase());
|
||||
if keywords.iter().all(|k| hay.contains(k.as_str())) {
|
||||
let date_added = node
|
||||
.get("date_added")
|
||||
.and_then(|v| v.as_str())
|
||||
.and_then(|s| s.parse::<i64>().ok())
|
||||
.unwrap_or(0);
|
||||
out.push(Hit {
|
||||
name: name.to_string(),
|
||||
url: url.to_string(),
|
||||
folder: folder.to_string(),
|
||||
date_added,
|
||||
});
|
||||
}
|
||||
}
|
||||
Some("folder") => {
|
||||
let fname = node.get("name").and_then(|v| v.as_str()).unwrap_or("");
|
||||
let child_folder = if folder.is_empty() {
|
||||
fname.to_string()
|
||||
} else {
|
||||
format!("{folder}/{fname}")
|
||||
};
|
||||
if let Some(children) = node.get("children").and_then(|c| c.as_array()) {
|
||||
for child in children {
|
||||
walk(child, &child_folder, keywords, out);
|
||||
}
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
||||
/// Resolve the Bookmarks file path for a browser + profile across platforms.
|
||||
fn bookmarks_path(browser: &str, profile: &str) -> Option<PathBuf> {
|
||||
let base = browser_user_data_dir(browser)?;
|
||||
let path = base.join(profile).join("Bookmarks");
|
||||
if path.exists() {
|
||||
Some(path)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
/// The "User Data" directory that holds per-profile folders, per OS/browser.
|
||||
fn browser_user_data_dir(browser: &str) -> Option<PathBuf> {
|
||||
let is_edge = browser == "edge" || browser == "msedge";
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
{
|
||||
let app_support = dirs::config_dir()?; // ~/Library/Application Support
|
||||
let sub = if is_edge {
|
||||
"Microsoft Edge"
|
||||
} else {
|
||||
"Google/Chrome"
|
||||
};
|
||||
Some(app_support.join(sub))
|
||||
}
|
||||
#[cfg(target_os = "windows")]
|
||||
{
|
||||
let local = dirs::data_local_dir()?; // %LOCALAPPDATA%
|
||||
let sub = if is_edge {
|
||||
"Microsoft/Edge/User Data"
|
||||
} else {
|
||||
"Google/Chrome/User Data"
|
||||
};
|
||||
Some(local.join(sub))
|
||||
}
|
||||
#[cfg(all(unix, not(target_os = "macos")))]
|
||||
{
|
||||
let config = dirs::config_dir()?; // ~/.config
|
||||
let sub = if is_edge {
|
||||
"microsoft-edge"
|
||||
} else {
|
||||
"google-chrome"
|
||||
};
|
||||
Some(config.join(sub))
|
||||
}
|
||||
}
|
||||
|
||||
fn emit_error(json: bool, msg: &str) {
|
||||
if json {
|
||||
println!(
|
||||
"{}",
|
||||
serde_json::to_string(&serde_json::json!({
|
||||
"success": false,
|
||||
"error": msg,
|
||||
}))
|
||||
.unwrap_or_default()
|
||||
);
|
||||
} else {
|
||||
eprintln!("{} {msg}", color::error_indicator());
|
||||
}
|
||||
std::process::exit(1);
|
||||
}
|
||||
@@ -3,6 +3,7 @@ mod color;
|
||||
mod commands;
|
||||
mod connection;
|
||||
mod doctor;
|
||||
mod findurl;
|
||||
mod flags;
|
||||
mod install;
|
||||
mod native;
|
||||
@@ -631,6 +632,15 @@ fn main() {
|
||||
return;
|
||||
}
|
||||
|
||||
// Handle find-url (doesn't need daemon): search local bookmarks
|
||||
if matches!(
|
||||
clean.first().map(|s| s.as_str()),
|
||||
Some("find-url") | Some("findurl")
|
||||
) {
|
||||
findurl::run_find_url(&clean, flags.json);
|
||||
return;
|
||||
}
|
||||
|
||||
// Handle session separately (doesn't need daemon)
|
||||
if clean.first().map(|s| s.as_str()) == Some("session") {
|
||||
run_session(&clean, &flags.session, flags.json);
|
||||
|
||||
@@ -15,7 +15,111 @@ pub async fn click(
|
||||
click_count: i32,
|
||||
iframe_sessions: &HashMap<String, String>,
|
||||
) -> Result<(), String> {
|
||||
let (x, y, effective_session_id) = resolve_element_center(
|
||||
// AGENT_BROWSER_CLICK_MODE: "" (default) = coordinate click with a DOM
|
||||
// fallback; "coord" = strict coordinate only (no fallback); "dom" = always
|
||||
// dispatch through the DOM.
|
||||
let mode = std::env::var("AGENT_BROWSER_CLICK_MODE").unwrap_or_default();
|
||||
|
||||
// (A) Scroll the target into view first so the computed coordinates land
|
||||
// inside the viewport. Without this, an element below the fold (or revealed
|
||||
// after scroll/popup) yields off-viewport coordinates and the click lands on
|
||||
// whatever currently occupies that point. Best-effort: ignore failures.
|
||||
scroll_into_view_if_needed(client, session_id, ref_map, selector_or_ref, iframe_sessions).await;
|
||||
|
||||
if mode == "dom" {
|
||||
return dom_click(client, session_id, ref_map, selector_or_ref, iframe_sessions).await;
|
||||
}
|
||||
|
||||
let resolved = resolve_element_center(
|
||||
client,
|
||||
session_id,
|
||||
ref_map,
|
||||
selector_or_ref,
|
||||
iframe_sessions,
|
||||
)
|
||||
.await;
|
||||
|
||||
match resolved {
|
||||
Ok((x, y, effective_session_id)) => {
|
||||
dispatch_click(client, &effective_session_id, x, y, button, click_count).await
|
||||
}
|
||||
Err(e) => {
|
||||
// (B) The coordinate path failed — typically a persistent overlay
|
||||
// failing the occlusion guard, or coordinates that won't resolve.
|
||||
// Fall back to a DOM-dispatched `.click()` on the intended element,
|
||||
// which targets the element directly instead of a screen point.
|
||||
// Skipped for strict "coord" mode and for non-left / multi-clicks
|
||||
// (a DOM `.click()` can't express right/middle/double semantics).
|
||||
if mode == "coord" || button != "left" || click_count != 1 {
|
||||
return Err(e);
|
||||
}
|
||||
eprintln!(
|
||||
"[click] coordinate click failed ({e}); falling back to DOM dispatch \
|
||||
(set AGENT_BROWSER_CLICK_MODE=coord to disable)"
|
||||
);
|
||||
dom_click(client, session_id, ref_map, selector_or_ref, iframe_sessions)
|
||||
.await
|
||||
.map_err(|dom_err| format!("{e}\n(DOM-dispatch fallback also failed: {dom_err})"))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Best-effort scroll-into-view before a coordinate click. Uses Chrome's
|
||||
/// `scrollIntoViewIfNeeded` (only scrolls when not already fully visible),
|
||||
/// falling back to centered `scrollIntoView`. Resolution failures are ignored —
|
||||
/// the subsequent resolve will surface a real "not found" error.
|
||||
async fn scroll_into_view_if_needed(
|
||||
client: &CdpClient,
|
||||
session_id: &str,
|
||||
ref_map: &RefMap,
|
||||
selector_or_ref: &str,
|
||||
iframe_sessions: &HashMap<String, String>,
|
||||
) {
|
||||
let Ok((object_id, effective_session_id)) = resolve_element_object_id(
|
||||
client,
|
||||
session_id,
|
||||
ref_map,
|
||||
selector_or_ref,
|
||||
iframe_sessions,
|
||||
)
|
||||
.await
|
||||
else {
|
||||
return;
|
||||
};
|
||||
let js = "function() { try { \
|
||||
if (typeof this.scrollIntoViewIfNeeded === 'function') { this.scrollIntoViewIfNeeded(true); } \
|
||||
else { this.scrollIntoView({ block: 'center', inline: 'center' }); } \
|
||||
} catch (e) {} }";
|
||||
let _ = client
|
||||
.send_command_typed::<_, Value>(
|
||||
"Runtime.callFunctionOn",
|
||||
&CallFunctionOnParams {
|
||||
function_declaration: js.to_string(),
|
||||
object_id: Some(object_id),
|
||||
arguments: None,
|
||||
return_by_value: Some(true),
|
||||
await_promise: Some(false),
|
||||
},
|
||||
Some(&effective_session_id),
|
||||
)
|
||||
.await;
|
||||
// Let the scroll settle so the following getBoxModel sees final coordinates.
|
||||
wait_for_paint_settled(client, &effective_session_id).await;
|
||||
}
|
||||
|
||||
/// Dispatch a click through the DOM (`element.click()`) instead of via screen
|
||||
/// coordinates. Targets the intended element directly, so it works when a
|
||||
/// floating layer occludes the click point or the element sits in a portal that
|
||||
/// confuses `elementFromPoint`. Used as the fallback for `click` and when
|
||||
/// `AGENT_BROWSER_CLICK_MODE=dom`.
|
||||
async fn dom_click(
|
||||
client: &CdpClient,
|
||||
session_id: &str,
|
||||
ref_map: &RefMap,
|
||||
selector_or_ref: &str,
|
||||
iframe_sessions: &HashMap<String, String>,
|
||||
) -> Result<(), String> {
|
||||
let (object_id, effective_session_id) = resolve_element_object_id(
|
||||
client,
|
||||
session_id,
|
||||
ref_map,
|
||||
@@ -23,7 +127,21 @@ pub async fn click(
|
||||
iframe_sessions,
|
||||
)
|
||||
.await?;
|
||||
dispatch_click(client, &effective_session_id, x, y, button, click_count).await
|
||||
client
|
||||
.send_command_typed::<_, Value>(
|
||||
"Runtime.callFunctionOn",
|
||||
&CallFunctionOnParams {
|
||||
function_declaration: "function() { this.click(); }".to_string(),
|
||||
object_id: Some(object_id),
|
||||
arguments: None,
|
||||
return_by_value: Some(true),
|
||||
await_promise: Some(false),
|
||||
},
|
||||
Some(&effective_session_id),
|
||||
)
|
||||
.await?;
|
||||
wait_for_paint_settled(client, &effective_session_id).await;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub async fn dblclick(
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "agent-browser-stealth",
|
||||
"version": "0.27.0-fork.15",
|
||||
"version": "0.27.0-fork.17",
|
||||
"description": "Browser automation CLI for AI agents — stealth fork with anti-detection",
|
||||
"type": "module",
|
||||
"packageManager": "pnpm@11.1.3",
|
||||
|
||||
@@ -29,6 +29,45 @@ Refs (`@e1`, `@e2`, ...) are assigned fresh on every snapshot. They become
|
||||
submits, dynamic re-renders, dialog opens. Always re-snapshot before your
|
||||
next ref interaction.
|
||||
|
||||
## Before you automate: pick the cheapest tool
|
||||
|
||||
Driving a browser is the heavy option. agent-browser earns its keep when you
|
||||
need a **real, logged-in browser** — not for reading text off a public page.
|
||||
|
||||
| You need | Use |
|
||||
|---|---|
|
||||
| Discover what exists / find sources | `WebSearch` |
|
||||
| Specific facts from a static or public page | `WebFetch` or `curl` (no browser) |
|
||||
| Login state, interaction, JS-rendered or anti-bot pages | **agent-browser** (this skill) |
|
||||
| A page the user saved before / an internal system | `agent-browser find-url <keywords>` (their bookmarks), then open it |
|
||||
|
||||
Don't hand-build deep URLs with query params — links discovered by *interacting*
|
||||
with the site carry the right hidden context and dodge anti-bot checks; a
|
||||
hand-constructed URL often doesn't.
|
||||
|
||||
## Two ways to drive a page — and when to drop to `eval`
|
||||
|
||||
You have a **real Chrome with the user's DOM**. Two layers, mix them freely:
|
||||
|
||||
1. **Structured** (`snapshot` + `@ref`, `find`, typed actions) — convenient and
|
||||
readable; best for straightforward forms and navigation. But the a11y view is
|
||||
*lossy and fragile*: refs go stale on any change, hidden inputs never show up,
|
||||
overlays can block coordinate clicks.
|
||||
2. **eval-first** (`agent-browser eval "<js>"`) — your eyes and hands on the real
|
||||
DOM: read hidden inputs, reach into Shadow DOM / iframes, inspect
|
||||
`form.elements` and `.validity`, extract the exact shape you want, or call
|
||||
`el.click()` directly. **The moment the structured path fights you, drop to
|
||||
`eval` instead of retrying it** — it's the fast way to find *why* something
|
||||
failed (e.g. a hidden `point_choice=none` the UI never exposes).
|
||||
|
||||
```bash
|
||||
# "what's actually in this form / why won't it submit?"
|
||||
agent-browser eval "[...document.forms[0].elements].map(e=>[e.name,e.type,e.value,e.checked])"
|
||||
agent-browser eval "document.querySelector('[name=point_choice]')?.value"
|
||||
agent-browser eval "[...document.forms[0].elements].filter(e=>!e.validity.valid).map(e=>e.name+': '+e.validationMessage)"
|
||||
agent-browser eval "document.querySelector('#stubborn').click()" # direct DOM click, bypasses overlays
|
||||
```
|
||||
|
||||
## Quickstart
|
||||
|
||||
```bash
|
||||
@@ -137,9 +176,17 @@ agent-browser fill "input[name=email]" "user@test.com"
|
||||
agent-browser click "button.primary"
|
||||
```
|
||||
|
||||
Rule of thumb: snapshot + `@eN` refs are fastest and most reliable for
|
||||
AI agents. `find role/text/label` is next best and doesn't require a prior
|
||||
snapshot. Raw CSS is a fallback when the others fail.
|
||||
Escalation ladder: snapshot + `@eN` refs are quickest for straightforward
|
||||
pages → `find role/text/label` when you'd rather skip the snapshot → raw CSS
|
||||
→ **`eval` the moment any of those fight you** (stale refs, hidden state,
|
||||
occluded clicks). Don't retry a flaky structured locator three times; drop to
|
||||
`eval` and act on the DOM directly.
|
||||
|
||||
`click` auto-scrolls into view and, if the coordinate click is occluded, falls
|
||||
back to a DOM `.click()`. If a click *reports success but nothing happened* —
|
||||
classic for an autocomplete/menu `<li>` that closes on the input's blur — retry
|
||||
that one with `AGENT_BROWSER_CLICK_MODE=dom agent-browser click ...`, or just
|
||||
`agent-browser eval "<select the item via JS>"`.
|
||||
|
||||
## Waiting (read this)
|
||||
|
||||
@@ -209,6 +256,44 @@ AGENT_BROWSER_SESSION_NAME=my-app agent-browser open https://app.example.com
|
||||
# State is auto-saved and restored on subsequent runs with the same name.
|
||||
```
|
||||
|
||||
### Remember a site's quirks (site notes)
|
||||
|
||||
A site behaves the same every time you visit it. When you work out something
|
||||
durable — a working selector, a URL pattern, a hidden field a form needs, an
|
||||
anti-bot trap, what requires login — **write it down so the next run doesn't
|
||||
re-discover it.** Keep one markdown file per domain (these are your own notes,
|
||||
not shipped with the skill):
|
||||
|
||||
```
|
||||
~/.agent-browser/site-patterns/<domain>.md
|
||||
```
|
||||
|
||||
**Before** working on a domain, read its file if it exists (use your normal file
|
||||
tools — this is plain markdown you own). Treat it as *hints, not guarantees* —
|
||||
sites change; verify before relying. **After** a successful session that taught
|
||||
you something durable, create or update it. Suggested shape:
|
||||
|
||||
```markdown
|
||||
---
|
||||
domain: app.example.com
|
||||
updated: 2026-06-05
|
||||
---
|
||||
## Platform traits
|
||||
SPA; form renders ~1s after load (wait --text). Cloudflare on /login.
|
||||
|
||||
## Working patterns
|
||||
- Address pick: the `<li>` closes on blur — select with CLICK_MODE=dom.
|
||||
- Submit needs hidden `point_choice` set (eval), the UI never exposes it.
|
||||
- Stable selector for "Continue": button[data-testid=submit]
|
||||
|
||||
## Known traps (date them)
|
||||
- 2026-06-05: @ref to the basket button goes stale after the mini-cart opens;
|
||||
re-snapshot or use `find role button --name "Checkout"`.
|
||||
```
|
||||
|
||||
This is how repeat visits get fast and reliable instead of re-solving the same
|
||||
page every time.
|
||||
|
||||
### Extract data
|
||||
|
||||
```bash
|
||||
|
||||
@@ -324,9 +324,9 @@ agent-browser <command> --help # Show detailed help for a command
|
||||
agent-browser --headed open example.com # Show browser window
|
||||
agent-browser --cdp 9222 snapshot # Connect via CDP port
|
||||
agent-browser connect 9222 # Alternative: connect command
|
||||
agent-browser console # View console messages
|
||||
agent-browser console # View console messages (needs AGENT_BROWSER_CAPTURE_CONSOLE=1)
|
||||
agent-browser console --clear # Clear console
|
||||
agent-browser errors # View page errors
|
||||
agent-browser errors # View page errors (needs AGENT_BROWSER_CAPTURE_CONSOLE=1)
|
||||
agent-browser errors --clear # Clear errors
|
||||
agent-browser highlight @e1 # Highlight element
|
||||
agent-browser inspect # Open Chrome DevTools for this session
|
||||
@@ -336,6 +336,41 @@ agent-browser profiler start # Start Chrome DevTools profiling
|
||||
agent-browser profiler stop trace.json # Stop and save profile
|
||||
```
|
||||
|
||||
### Finding a page the user saved (`find-url`)
|
||||
|
||||
Search the user's local Chrome/Edge **bookmarks** by keyword — for internal
|
||||
systems or previously-saved pages that public search can't reach. Local read, no
|
||||
browser/daemon needed.
|
||||
|
||||
```bash
|
||||
agent-browser find-url jira board # all keywords must match (name or url)
|
||||
agent-browser find-url --limit 10 invoices
|
||||
agent-browser find-url --browser edge --profile "Profile 1" wiki
|
||||
agent-browser find-url grafana --json # {results:[{name,url,folder}], count}
|
||||
```
|
||||
|
||||
Results are most-recently-added first. `javascript:`/`data:` bookmarklets are
|
||||
skipped. (Visited-history search isn't included yet — bookmarks only.)
|
||||
|
||||
### Debugging forms / hidden state with `eval`
|
||||
|
||||
The a11y `snapshot` shows visible, interactive elements — it does **not** show
|
||||
hidden inputs or a control's actual submitted value. When a form "looks filled"
|
||||
but submit-validation rejects it, go straight to the DOM with `eval` instead of
|
||||
guessing from the snapshot. This is usually the fastest way to find the real
|
||||
problem (e.g. a hidden `point_choice=none` that the visible UI never exposes):
|
||||
|
||||
```bash
|
||||
# Dump every field's name → value, including hidden inputs and unchecked radios
|
||||
agent-browser eval "JSON.stringify([...document.forms[0].elements].map(e=>({name:e.name,type:e.type,value:e.value,checked:e.checked})).filter(e=>e.name))"
|
||||
|
||||
# Inspect one hidden field directly
|
||||
agent-browser eval "document.querySelector('[name=point_choice]')?.value"
|
||||
|
||||
# Why won't it submit? Ask the browser's own validity API
|
||||
agent-browser eval "[...document.forms[0].elements].filter(e=>!e.validity?.valid).map(e=>e.name+': '+e.validationMessage)"
|
||||
```
|
||||
|
||||
## React / Web Vitals
|
||||
|
||||
Requires `--enable react-devtools` at launch for the `react ...` commands.
|
||||
@@ -391,4 +426,38 @@ AGENT_BROWSER_HIDE_SCROLLBARS="false" # Keep native scrollbars visible in
|
||||
AGENT_BROWSER_PROVIDER="browserbase" # Cloud browser provider
|
||||
AGENT_BROWSER_STREAM_PORT="9223" # Override WebSocket streaming port (default: OS-assigned)
|
||||
AGENT_BROWSER_HOME="/path/to/agent-browser" # Custom install location
|
||||
AGENT_BROWSER_CLICK_MODE="dom" # Click strategy: "" (default: scroll-in + coordinate
|
||||
# click, DOM-dispatch fallback), "coord" (strict
|
||||
# coordinate only), "dom" (always element.click())
|
||||
```
|
||||
|
||||
### Click reliability
|
||||
|
||||
`click` auto-scrolls the target into view first, then dispatches a coordinate
|
||||
click. If that fails (a floating layer fails the occlusion guard, or the point
|
||||
won't resolve) it falls back to a DOM-dispatched `.click()` on the intended
|
||||
element. If a click *reports success but the page didn't react* — common for
|
||||
autocomplete/menu `<li>` items that close on the input's blur — retry that one
|
||||
with `AGENT_BROWSER_CLICK_MODE=dom` (a DOM dispatch doesn't move focus the way a
|
||||
real pointer press does, so the item still selects). `=coord` disables the
|
||||
fallback when you specifically want a hard failure on occlusion.
|
||||
|
||||
### Stealth / anti-detection knobs (fork)
|
||||
|
||||
```bash
|
||||
AGENT_BROWSER_CAPTURE_CONSOLE="1" # Enable `console`/`errors` capture. OFF by default:
|
||||
# a live CDP Runtime domain is a detectable bot signal,
|
||||
# so console/errors return empty (with a hint) until set.
|
||||
AGENT_BROWSER_TIMEZONE="Asia/Tokyo" # --launch only. Native timezone override (IANA id, or
|
||||
# "auto" to derive from locale). Aligns Intl+Date to a proxy.
|
||||
AGENT_BROWSER_BLOCK_WEBRTC="1" # --launch only. Hide local IP via WebRTC. Auto-forces WebRTC
|
||||
# through the proxy when one is set; "0" opts out.
|
||||
AGENT_BROWSER_HIDE_CANVAS="1" # --launch only. Session-stable canvas/audio fingerprint noise.
|
||||
AGENT_BROWSER_ADAPTIVE_REF="0" # Disable adaptive @ref relocation (on by default; relocates a
|
||||
# moved element by fingerprint when role/name re-query fails).
|
||||
```
|
||||
|
||||
> **Heads-up for `console` / `errors`:** capture is **off by default** in this stealth
|
||||
> fork. Both commands return `{"messages":[]}` / `{"errors":[]}` plus a `hint` until you
|
||||
> launch the session with `AGENT_BROWSER_CAPTURE_CONSOLE=1`. This keeps the CDP `Runtime`
|
||||
> domain disabled (a known bot signal) for the common automation path.
|
||||
|
||||
@@ -96,7 +96,7 @@ Read [references/issue-taxonomy.md](references/issue-taxonomy.md) for the full l
|
||||
- Within each section, test interactive elements: click buttons, fill forms, open dropdowns/modals.
|
||||
- Check edge cases: empty states, error handling, boundary inputs.
|
||||
- Try realistic end-to-end workflows (create, edit, delete flows).
|
||||
- Check the browser console for errors periodically.
|
||||
- Check the browser console for errors periodically. **Console/error capture is off by default in this stealth fork** — start the dogfood session with `AGENT_BROWSER_CAPTURE_CONSOLE=1` (e.g. `AGENT_BROWSER_CAPTURE_CONSOLE=1 agent-browser --session {SESSION} open <url>`) or `console`/`errors` will return empty.
|
||||
|
||||
**At each page:**
|
||||
|
||||
|
||||
@@ -230,6 +230,9 @@ agent-browser snapshot -i | grep -c "treeitem"
|
||||
|
||||
### Check console for errors
|
||||
|
||||
Console/error capture is off by default in this stealth fork — launch the session with
|
||||
`AGENT_BROWSER_CAPTURE_CONSOLE=1` first, or these return empty.
|
||||
|
||||
```bash
|
||||
agent-browser console
|
||||
agent-browser errors
|
||||
|
||||
Reference in New Issue
Block a user