📄 playwright-python/python/docs/frames

File: frames.md | Updated: 11/18/2025

Source: https://playwright.dev/python/docs/frames

Skip to main content

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.

  • Sync

  • Async

    Locate element inside frame# Get frame using any other selectorusername = page.frame_locator('.frame-class').get_by_label('User Name')username.fill('John')

    Locate element inside frameusername = await page.frame_locator('.frame-class').get_by_label('User Name')await username.fill('John')

Frame objects


One can access frame objects using the page.frame() API:

  • Sync

  • Async

    Get frame using the frame's name attributeframe = page.frame('frame-login')# Get frame using frame's URLframe = page.frame(url=r'.domain.')# Interact with the frameframe.fill('#username-input', 'John')

    Get frame using the frame's name attributeframe = page.frame('frame-login')# Get frame using frame's URLframe = page.frame(url=r'.domain.')# Interact with the frameawait frame.fill('#username-input', 'John')

  • Introduction

  • Frame objects