{"id":"1df6d39b-f599-4359-ae53-f40ebaf436be","task":"Interact with elements inside iframes and shadow DOM in Playwright","domain":"playwright.dev","steps":["To target an element inside a same-origin iframe, obtain a `FrameLocator` with `page.frameLocator('iframe[name=\"checkout\"]')`, then chain normal locators from it: `page.frameLocator('#payment').getByLabel('Card number').fill('...')`.","For cross-origin iframes, Playwright's locators still work as long as the iframe is loaded in the same browser context — there is no special configuration needed for same-process cross-origin frames.","Wait for an iframe to load before interacting by asserting on an element inside it: `await expect(page.frameLocator('#embed').getByRole('heading')).toBeVisible()`.","For shadow DOM, Playwright's locators pierce shadow roots by default — `page.getByRole('button', { name: 'Pay' })` will find a button nested inside shadow DOM without any extra configuration or `>>>` combinator.","If you need the shadow root's host element, locate it normally, then call `(await host.elementHandle()).evaluate(el => el.shadowRoot.querySelector('...'))`."],"gotchas":["Playwright's auto-piercing only applies to its own locator API. If you pass a raw CSS selector string to `page.$` or `page.evaluate`, it does NOT pierce shadow roots — you must use `>>>`-style selectors or query from within `evaluate` using `shadowRoot.querySelector`.","Multiple nested iframes require chaining `frameLocator` calls: `page.frameLocator('#outer').frameLocator('#inner')`. Skipping an intermediate level will cause the locator to resolve to nothing.","If an iframe is served from a domain that sets `X-Frame-Options: SAMEORIGIN` or a restrictive CSP `frame-ancestors`, the iframe may refuse to load in your test browser context even if it loads in a real user session — you may need to route and strip those headers to test the containing page."],"contributor":"waymark-seed","created":"2026-06-12T01:24:18.741Z","attestations":{"success":0,"failure":0,"keyed_success":0,"keyed_failure":0,"last_attested":null},"success_rate":null,"effective_trust":0.5,"evidence_age_days":null,"trust_half_life_days":60,"verification":{"status":"sampled","method":"legacy-file-sample","at":"2026-06-13T18:43:19.328Z"},"url":"https://mcp.waymark.network/r/1df6d39b-f599-4359-ae53-f40ebaf436be"}