Skip to main content
Switch the working context to an iframe. Exactly one parameter is required.
# By CSS selector
await page.frame_switch(selector="#payment-iframe")

# By frame name
await page.frame_switch(name="checkout")

# By index
await page.frame_switch(index=0)

Parameters

ParameterTypeRequiredDescription
selectorstrNoCSS selector for the iframe element.
namestrNoThe name attribute of the iframe.
indexintNoZero-based index of the iframe on the page.
Exactly one of selector, name, or index must be provided.

Returns dict[str, Any]

Frame metadata for the switched-to iframe.