pilot_drag
Drag elements between positions in a browser using source and target references for browser automation tasks.
Instructions
Drag from one element to another.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| start_ref | Yes | Source element ref or CSS selector | |
| end_ref | Yes | Target element ref or CSS selector |
Implementation Reference
- src/tools/interaction.ts:176-201 (handler)The 'pilot_drag' tool handler implementation, which uses Playwright's `dragTo` method to perform a drag-and-drop operation between two elements.
server.tool( 'pilot_drag', 'Drag from one element to another.', { start_ref: z.string().describe('Source element ref or CSS selector'), end_ref: z.string().describe('Target element ref or CSS selector'), }, async ({ start_ref, end_ref }) => { await bm.ensureBrowser(); try { const page = bm.getPage(); const startResolved = await bm.resolveRef(start_ref); const endResolved = await bm.resolveRef(end_ref); const startLocator = 'locator' in startResolved ? startResolved.locator : page.locator(startResolved.selector); const endLocator = 'locator' in endResolved ? endResolved.locator : page.locator(endResolved.selector); await startLocator.dragTo(endLocator, { timeout: 5000 }); bm.resetFailures(); return { content: [{ type: 'text' as const, text: `Dragged ${start_ref} → ${end_ref}` }] }; } catch (err) { bm.incrementFailures(); return { content: [{ type: 'text' as const, text: wrapError(err) }], isError: true }; } } );