arrow-left Back to topicQuizFramesCheck yourself1.Your checkout page embeds a payment form inside an iframe from a payment provider. You try page.getByLabel('Card number').fill('4242...') but Playwright throws 'No element found'. Why, and how do you fix it?The label text is wrong — check the actual label in DevToolspage locators only search the main frame's DOM — the input is inside an iframe. Fix: use page.frameLocator('iframe[title=...]').getByLabel('Card number').fill('4242...')Payment iframes block automation — you need to use the API to test payment flows2.How do you get a Frame object by its name attribute using the Playwright API?page.frameLocator('[name="frame-login"]')page.frame('frame-login') — passing the name string directlypage.querySelector('iframe[name="frame-login"]').contentDocumentpage.frames().find(f => f.name === 'frame-login')3.What is the key difference between page.frameLocator() and page.frame()?frameLocator() is faster; frame() is more accurateframeLocator() returns a FrameLocator for element interaction using locators; frame() returns the raw Frame object for JavaScript evaluation and metadata accessframeLocator() works for nested iframes; frame() only works for top-level iframesThey are identical — frameLocator is deprecated in favor of frame4.How do you interact with an element inside a nested iframe (an iframe inside an iframe)?page.frame('#outer-frame').frame('#inner-frame').getByRole('button')page.frameLocator('#outer-frame').frameLocator('#inner-frame').getByRole('button')page.getByRole('button') — Playwright automatically searches all nested iframesNested iframes are not supported — you must flatten them first5.You need to get the URL of a frame to verify it loaded the correct page. Which API do you use?page.frameLocator('iframe').url()page.frame({ url: /pattern/ }) to find it, then frame.url() on the Frame objectpage.evaluate(() => document.querySelector('iframe').src)page.getAttribute('iframe', 'src') — src always equals the current URL6.How do you wait for a specific iframe to finish loading before interacting with its contents?await page.waitForTimeout(2000) before accessing the frameUse frameLocator().getByRole() — Playwright auto-waits for the element to appear inside the frameawait page.frame('myFrame').waitForLoadState('networkidle')Both b and c are correct approaches7.What does page.frames() return?An array of FrameLocator objects for all iframes on the pageAn array of all Frame objects currently attached to the page, including the main frameOnly the child iframes — the main frame is excludedAn array of iframe DOM elements (HTMLIFrameElement)8.You want to run JavaScript inside a specific iframe to read a value from its window object. Which approach is correct?page.evaluate(() => window.iframeValue) — evaluate runs in all framesconst frame = page.frame('myFrame'); const value = await frame.evaluate(() => window.iframeValue)page.frameLocator('iframe').evaluate(() => window.iframeValue)You cannot run JavaScript inside iframes from Playwright testsSubmit answersarrow-left PreviousIsolationDialogsNext arrow-right