111 / 168 · 01 Agent Skills for Browser Automation · WebDriver BiDi Protocol Overview← prev⊞ allnext →☰ Read as one page
15.3Core Modules
Session Module
Manages the connection between client and browser.
// Create session
{"id": 1, "method": "session.new", "params": {"capabilities": {}}}
// Subscribe to events
{"id": 2, "method": "session.subscribe", "params": {"events": ["log.entryAdded"]}}
Browsing Context Module
Manages tabs, iframes, and navigation.
// Navigate
{"id": 3, "method": "browsingContext.navigate", "params": {"context": "ctx-1", "url": "https://example.com"}}
// Get tree (all tabs and iframes)
{"id": 4, "method": "browsingContext.getTree", "params": {}}
// Create new tab
{"id": 5, "method": "browsingContext.create", "params": {"type": "tab"}}
// Close tab
{"id": 6, "method": "browsingContext.close", "params": {"context": "ctx-1"}}
Script Module
Execute JavaScript in the browser context.
// Evaluate expression
{"id": 7, "method": "script.evaluate", "params": {
"expression": "document.title",
"target": {"context": "ctx-1"},
"awaitPromise": true
}}
// Call function (more powerful - can pass arguments)
{"id": 8, "method": "script.callFunction", "params": {
"functionDeclaration": "(selector) => document.querySelector(selector)?.textContent",
"arguments": [{"type": "string", "value": "h1"}],
"target": {"context": "ctx-1"},
"awaitPromise": true
}}
Input Module
Simulate user input (mouse, keyboard).
// Click at coordinates
{"id": 9, "method": "input.performActions", "params": {
"context": "ctx-1",
"actions": [{
"type": "pointer",
"id": "mouse",
"actions": [
{"type": "pointerMove", "x": 200, "y": 300},
{"type": "pointerDown", "button": 0},
{"type": "pointerUp", "button": 0}
]
}]
}}
// Type text
{"id": 10, "method": "input.performActions", "params": {
"context": "ctx-1",
"actions": [{
"type": "key",
"id": "keyboard",
"actions": [
{"type": "keyDown", "value": "H"},
{"type": "keyUp", "value": "H"},
{"type": "keyDown", "value": "i"},
{"type": "keyUp", "value": "i"}
]
}]
}}
Network Module
Intercept and inspect network requests. (Once "future," now real: as of 2026 BiDi covers roughly 70% of the CDP surface across Chrome and Firefox, and network interception is part of it.)
// Enable network tracking
{"id": 11, "method": "network.addIntercept", "params": {
"phases": ["beforeRequestSent"]
}}
// Event: request made
{"method": "network.beforeRequestSent", "params": {
"request": {"url": "https://api.example.com/data", "method": "GET"}
}}
Log Module
Console log events pushed from the browser.
// Subscribe
{"id": 12, "method": "session.subscribe", "params": {"events": ["log.entryAdded"]}}
// Event received
{"method": "log.entryAdded", "params": {
"level": "error",
"text": "TypeError: x is not a function",
"source": {"realm": "realm-1"},
"timestamp": 1707500000000
}}