Extract a visual contract
extract_contractExtracts a visual contract from a reference URL and saves it as JSON, providing the baseline needed for implementation checks or pixel diffs.
Instructions
Extracts a visual contract from a reference URL and saves it as JSON at outputPath. Call this once per reference design, before check_implementation or diff_pixels can be used, since both need a saved contract to compare against. Pass screenshotDir to also capture reference screenshots, which diff_pixels requires later. Returns a summary: the element count per viewport, any extraction warnings, and the path the contract was written to.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| url | Yes | The reference URL to extract a visual contract from. | |
| wait | No | Extra settle time in milliseconds after navigation. Defaults to 2000. | |
| masks | No | CSS selectors to exclude from the walk, for example ads or timestamps. | |
| timeout | No | Navigation timeout in milliseconds. Defaults to 30000. | |
| fullPage | No | Capture the full scrollable page instead of only the viewport. Defaults to true. | |
| headless | No | Run the browser headless. Defaults to true. | |
| selector | No | CSS selector to scope the walk to. Defaults to the document body. | |
| maxStates | No | Maximum interactive elements to probe for hover and focus. Defaults to 120. | |
| viewports | No | Viewports to capture. Defaults to desktop 1440x900, tablet 768x1024, mobile 390x844. | |
| outputPath | Yes | Filesystem path to write the contract JSON to, for example ./contracts/home.json. | |
| maxElements | No | Maximum elements to walk, 0 means unbounded. Defaults to 600. | |
| screenshotDir | No | Directory to save reference screenshots to. Required later for diff_pixels to work. | |
| freezeAnimations | No | Freeze CSS animations before measuring. Defaults to true. |