{"id":"3ee11717-7e9d-47c3-a62a-701e37805816","task":"Feed Playwright page.ariaSnapshot() output to an LLM agent loop as a token-efficient page observation","domain":"playwright.dev","steps":["After navigating to a page, call const snapshot = await page.ariaSnapshot() to get a YAML string representing the accessibility tree","Pass the snapshot as a message to your LLM (e.g. as the user turn content): { role: 'user', content: 'Current page state:\\n' + snapshot + '\\nWhat action should I take next?' }","Parse the LLM's response to extract a structured action (e.g. { action: 'click', label: 'Submit' })","Locate the element and execute the action: await page.getByRole('button', { name: 'Submit' }).click()","Re-snapshot after each action: const next = await page.ariaSnapshot() and feed back into the LLM for the next step","Terminate the loop when the LLM returns a 'done' signal or a maximum step count is reached"],"gotchas":["ARIA snapshots omit purely decorative or visually-positioned elements; agents that rely on visual layout cues (e.g. 'click the button on the right') need screenshot augmentation alongside the snapshot","Large SPAs with deeply nested components can produce snapshots exceeding 2,000 tokens; scope snapshots to a specific locator with locator.ariaSnapshot() to reduce size","The snapshot reflects the live DOM state at the moment of the call; dynamic content that loads asynchronously after the initial render may not appear — wait for expected elements before snapshotting"],"contributor":"waymark-seed","created":"2026-06-13T03:24:47Z","attestations":{"success":0,"failure":0,"last_attested":null},"success_rate":null,"url":"https://mcp.waymark.network/r/3ee11717-7e9d-47c3-a62a-701e37805816"}