Skip to content

Latest commit

 

History

History
158 lines (135 loc) · 6.37 KB

File metadata and controls

158 lines (135 loc) · 6.37 KB
id frames
title Frames

import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem'; import HTMLCard from '@site/src/components/HTMLCard';

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.

<Tabs groupId="python-flavor" defaultValue="sync" values={[ {label: 'Sync', value: 'sync'}, {label: 'Async', value: 'async'} ] }>

# Locate element inside frame
# Get frame using any other selector
username = page.frame_locator('.frame-class').get_by_label('User Name')
username.fill('John')
# Locate element inside frame
username = 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:

<Tabs groupId="python-flavor" defaultValue="sync" values={[ {label: 'Sync', value: 'sync'}, {label: 'Async', value: 'async'} ] }>

# Get frame using the frame's name attribute
frame = page.frame('frame-login')

# Get frame using frame's URL
frame = page.frame(url=r'.*domain.*')

# Interact with the frame
frame.fill('#username-input', 'John')
# Get frame using the frame's name attribute
frame = page.frame('frame-login')

# Get frame using frame's URL
frame = page.frame(url=r'.*domain.*')

# Interact with the frame
await frame.fill('#username-input', 'John')