Skip to Content
ReferenceToolsBrowser Tool

Browser Tool

The browser tool enables AI agents to automate web browser interactions using agent-browser .

Requirements

npm install -g agent-browser agent-browser install # Downloads Chrome

Core Actions

// Open a URL browser({ action: 'open', url: 'https://example.com' }); // Close browser browser({ action: 'close' }); // Navigate to new tab browser({ action: 'tab', text: 'new', url: 'https://example.com' });

Element Interaction

// Click an element browser({ action: 'click', selector: '@e2' }); // Double-click browser({ action: 'dblclick', selector: '@e2' }); // Hover browser({ action: 'hover', selector: '@e2' }); // Fill input (clears then types) browser({ action: 'fill', selector: '@e2', text: 'user@example.com' }); // Type (appends) browser({ action: 'type', selector: '@e2', text: ' more text' }); // Press key browser({ action: 'press', key: 'Enter' });

Page Inspection

// Get accessibility tree with interactive elements browser({ action: 'snapshot', flags: JSON.stringify({ interactive: true }) }); // Take screenshot browser({ action: 'screenshot', outputPath: '/path/to/screenshot.png' }); // Full page screenshot browser({ action: 'screenshot', outputPath: '/path/to/full.png', flags: JSON.stringify({ full: true }), }); // Get page title browser({ action: 'get', text: 'title' }); // Get current URL browser({ action: 'get', text: 'url' }); // Get element text browser({ action: 'get', selector: '@e1', text: 'text' }); // Check if visible browser({ action: 'is', text: 'visible', selector: '@e1' });

Waiting

// Wait for URL pattern browser({ action: 'wait', text: '**/dashboard' }); // Wait for text browser({ action: 'wait', text: 'Welcome' }); // Wait for network idle browser({ action: 'wait', text: 'networkidle' }); // Wait for selector browser({ action: 'wait', selector: '@e1' });

Batch Commands

Execute multiple commands in sequence:

browser({ action: 'batch', commands: [ 'open https://example.com', 'wait --load networkidle', 'fill @e1 user@example.com', 'fill @e2 password', 'click @e3', 'wait --url **/dashboard', ], });

Selector Types

TypeExampleDescription
Element ref@e1, @e2From snapshot output
CSS selector#id, .class, button.submitStandard CSS
Semanticrole:button, text:"Sign In"AI-friendly selectors

Sessions

Sessions persist authentication and cookies:

// Create session browser({ action: 'open', url: 'https://app.example.com', session: 'myapp' }); // Continue in same session browser({ action: 'click', selector: '@e1', session: 'myapp' });

All Actions (38 total)

ActionDescription
openNavigate to URL
closeClose browser
tabManage tabs
clickClick element
dblclickDouble-click element
hoverHover over element
fillFill form field
typeType into field
pressPress keyboard key
selectSelect dropdown option
check / uncheckToggle checkbox/radio
uploadUpload file
snapshotGet accessibility tree
screenshotCapture screenshot
getGet element/page property
isCheck element state
findFind element by role/text
waitWait for condition
batchExecute command batch
scrollScroll page/element
clipboardRead/write clipboard
mouseMouse movement
keyboardKeyboard control
windowWindow management
cookiesCookie management
storageLocal/session storage
networkNetwork interception
diffVisual diff
chatAI-assisted interaction
dashboardPerformance dashboard
consoleAccess console logs
errorsGet page errors
tracePerformance trace
profilerCPU profiler
inspectInspect element
evalEvaluate JavaScript
installInstall browser
profilesManage profiles

For detailed documentation on all actions, see the browser-automation skill via /skills.

Last updated on