-
Book Overview & Buying
-
Table Of Contents
Hands-On Automated Testing with Playwright
By :
Playwright sees every web page as a tree made up of frames. The main document is the primary or main frame, and any <iframe> elements inside it are treated as child frames. Some websites use iframes or even nested frames to organize content, often for security or to keep things modular. If you want to interact with something inside one of those frames, such as clicking a button or typing in a field, you’ll need to switch your focus to that specific frame so your actions happen in the right place.
An <iframe> element creates an inline frame that loads another HTML document. It operates as a separate browsing context, meaning elements inside an iframe are isolated from the parent page.
To work with elements inside an iframe, start by finding the iframe using frameLocator. Just call page.frameLocator(selector) and pass in the iframe’s CSS selector, ID, or another attribute to target it...