snapshot
Capture a snapshot of the current webpage including all interactive elements for documentation, testing, or analysis purposes.
Instructions
Get a snapshot of the current page with interactive elements
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- browser.js:138-165 (handler)Core handler method that captures the page snapshot including URL, title, and interactive elements by evaluating JavaScript on the page.async snapshot() { await this.ensureLaunched(); // Get basic page information const url = await this.getUrl(); const title = await this.getTitle(); // Extract all interactive elements from the page const elements = await this.page.evaluate(() => { const interactive = document.querySelectorAll('a, button, input, select, textarea, [onclick], [role="button"]'); return Array.from(interactive).map((el, index) => ({ index, tag: el.tagName.toLowerCase(), text: el.textContent?.trim() || el.value || el.placeholder || '', type: el.type || '', role: el.getAttribute('role') || '', id: el.id || '', className: el.className || '' })); }); // Return page snapshot with filtered interactive elements return { url, title, elements: elements.filter(el => el.text || el.id || el.className) }; }
- tools-playwright.js:141-157 (registration)Registers the 'snapshot' MCP tool with input schema and a handler that calls the browser.snapshot() method and formats the response.{ name: 'snapshot', description: 'Get a snapshot of the current page with interactive elements', inputSchema: { type: 'object', properties: {}, required: [] }, handler: async () => { const snapshot = await browser.snapshot(); return { success: true, data: snapshot, message: `Page snapshot captured for ${snapshot.url}` }; } },
- tools-playwright.js:144-148 (schema)Input schema for the 'snapshot' tool, which requires no parameters.inputSchema: { type: 'object', properties: {}, required: [] },