# 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[​](#usage "Direct link to Usage")

```
await browser.switchFrame(context)
```

## Parameters[​](#parameters "Direct link to Parameters")

| Name      | Type            | Details                                                   |
| --------- | --------------- | --------------------------------------------------------- |
| `context` | `Element, null` | frame element, or `null` for the top frame (Classic only) |

## Example[​](#example "Direct link to 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[​](#returns "Direct link to Returns")

* **\<void>**
