pilot_page_css
Retrieve computed CSS property values for web elements using element references or CSS selectors to inspect styling in browser automation.
Instructions
Get computed CSS property value for an element.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| ref | Yes | Element ref or CSS selector | |
| property | Yes | CSS property name (e.g. color, font-size) |
Implementation Reference
- src/tools/page.ts:137-159 (handler)The implementation of the pilot_page_css tool handler, which uses Playwright's locator to evaluate and retrieve the computed CSS property of a specified element.
server.tool( 'pilot_page_css', 'Get computed CSS property value for an element.', { ref: z.string().describe('Element ref or CSS selector'), property: z.string().describe('CSS property name (e.g. color, font-size)'), }, async ({ ref, property }) => { await bm.ensureBrowser(); try { const page = bm.getPage(); const resolved = await bm.resolveRef(ref); const locator = 'locator' in resolved ? resolved.locator : page.locator(resolved.selector); const value = await locator.evaluate( (el, prop) => getComputedStyle(el).getPropertyValue(prop), property ); return { content: [{ type: 'text' as const, text: value }] }; } catch (err) { return { content: [{ type: 'text' as const, text: wrapError(err) }], isError: true }; } } );