pilot_scroll
Scroll web pages to specific elements or directions using CSS selectors. Navigate to page top, bottom, or scroll up/down for browser automation tasks.
Instructions
Scroll element into view, or scroll to page bottom if no ref provided.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| ref | No | Element ref or CSS selector to scroll into view | |
| direction | No | Scroll direction (when no ref) |
Implementation Reference
- src/tools/interaction.ts:210-232 (handler)The handler function for the pilot_scroll MCP tool, which scrolls either a specific element into view or performs a general page scroll.
async ({ ref, direction }) => { await bm.ensureBrowser(); try { const page = bm.getPage(); if (ref) { const resolved = await bm.resolveRef(ref); if ('locator' in resolved) { await resolved.locator.scrollIntoViewIfNeeded({ timeout: 5000 }); } else { await page.locator(resolved.selector).scrollIntoViewIfNeeded({ timeout: 5000 }); } bm.resetFailures(); return { content: [{ type: 'text' as const, text: `Scrolled ${ref} into view` }] }; } const scrollMap: Record<string, string> = { up: 'window.scrollBy(0, -window.innerHeight)', down: 'window.scrollBy(0, window.innerHeight)', top: 'window.scrollTo(0, 0)', bottom: 'window.scrollTo(0, document.body.scrollHeight)', }; await page.evaluate(scrollMap[direction || 'bottom']); bm.resetFailures(); return { content: [{ type: 'text' as const, text: `Scrolled ${direction || 'bottom'}` }] }; - src/tools/interaction.ts:206-209 (schema)Zod schema defining the input arguments for the pilot_scroll tool.
{ ref: z.string().optional().describe('Element ref or CSS selector to scroll into view'), direction: z.enum(['up', 'down', 'top', 'bottom']).optional().describe('Scroll direction (when no ref)'), },