frameLocator by ID
In Playwright, use page.frameLocator(selector) to interact with elements inside iframes. Unlike Selenium, you don't "switch" context — you chain locators.
On the Frames page, the first #frame1 contains an <h1>CodeKru</h1>. The page has a second iframe with the same id (it shows CodeKru2), so page.frameLocator('#frame1') alone fails Playwright's strict mode. Add >> nth=0 to pick the first one.
Task:
- Navigate to
https://testkru.com/Interactions/Frames - Access the first
#frame1withpage.frameLocator(), adding thenthpart described above - Find the h1 inside the frame and print its text
Expected output:
Frame content: CodeKru
TestKru