File: frames.md | Updated: 11/18/2025
On this page
Introduction
A Page
can have one or more Frame
objects attached to it. Each page has a main frame and page-level interactions (like click) are assumed to operate in the main frame.
A page can have additional frames attached with the iframe HTML tag. These frames can be accessed for interactions inside the frame.
// Locate element inside framevar username = await page.FrameLocator(".frame-class").GetByLabel("User Name");await username.FillAsync("John");
Frame objects
One can access frame objects using the Page.Frame() API:
// Create a page.var page = await context.NewPageAsync();// Get frame using the frame's name attributevar frame = page.Frame("frame-login");// Get frame using frame's URLvar frame = page.FrameByUrl("*domain.");// Get frame using any other selectorvar frameElementHandle = await page.EvaluateAsync("window.frames[1]");var frame = await frameElementHandle.ContentFrameAsync();// Interact with the frameawait frame.FillAsync("#username-input", "John");