switchFrame
Switch the Classic session into a frame.
In a WebDriver BiDi session this command throws. Hold the browsing context
from browser.url() or browser.newWindow() and call context.frame().
context.parent is the frame you came from. There is no switchFrame(null).
In a Classic session, pass an element or null for the top frame. A string
or a function is rejected.
Usage​
await browser.switchFrame(context)
Parameters​
| Name | Type | Details |
|---|---|---|
context | Element, null | frame element, or null for the top frame (Classic only) |
Example​
switchFrame.js
// Classic
await browser.switchFrame($('iframe'))
await browser.switchFrame(null)
// BiDi
const page = await browser.url('https://example.com')
const child = await page.frame('iframe')
console.log(await child.getTitle())
Returns​
- <void>