browser_resize
Adjust browser window dimensions to test responsive web designs or simulate different screen sizes for automated testing.
Instructions
Resize the browser window
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| width | Yes | Width of the browser window | |
| height | Yes | Height of the browser window |
Implementation Reference
- src/tools/common.ts:51-58 (handler)The handler function for the 'browser_resize' tool. It adds explanatory code comments to the response and resizes the browser viewport to the specified width and height using the page.setViewportSize method within a waitForCompletion block.handle: async (tab, params, response) => { response.addCode(`// Resize browser window to ${params.width}x${params.height}`); response.addCode(`await page.setViewportSize({ width: ${params.width}, height: ${params.height} });`); await tab.waitForCompletion(async () => { await tab.page.setViewportSize({ width: params.width, height: params.height }); }); },
- src/tools/common.ts:40-49 (schema)Schema definition for the 'browser_resize' tool, including name, title, description, input schema validating width and height as numbers, and type as readOnly.schema: { name: 'browser_resize', title: 'Resize browser window', description: 'Resize the browser window', inputSchema: z.object({ width: z.number().describe('Width of the browser window'), height: z.number().describe('Height of the browser window'), }), type: 'readOnly', },
- src/tools.ts:36-52 (registration)Central registration of all tools, including 'browser_resize' via spreading the exports from common.ts (which defines browser_resize) into the allTools array.export const allTools: Tool<any>[] = [ ...common, ...console, ...dialogs, ...evaluate, ...files, ...install, ...keyboard, ...navigate, ...network, ...mouse, ...pdf, ...screenshot, ...snapshot, ...tabs, ...wait, ];