# navigate

Navigate this browsing context to a URL and wait until the page has loaded. It works for a tab, a window or a frame. Only this context navigates: other tabs keep their page, and the parents of a frame stay where they are.

`browser.url()` always navigates the session's first top-level browsing context, so use `navigate()` for any other one. It takes the same options as [`browser.url()`](/docs/api/browser/url.md), and a relative URL resolves against the `baseUrl` option. Returns this context, with `url` and `request` updated.

## Usage[​](#usage "Direct link to Usage")

```
const context = await browser.url('https://webdriver.io')

await context.navigate(url, { wait, timeout, onBeforeLoad, auth, headers })
```

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

| Name                                   | Type                | Details                                                                                 |
| -------------------------------------- | ------------------- | --------------------------------------------------------------------------------------- |
| `url`                                  | `string`            | the URL to navigate to, absolute or relative to `baseUrl`                               |
| `options`<br />*optional*              | `UrlCommandOptions` | navigation options, the same as for `browser.url()`                                     |
| `options.wait`<br />*optional*         | `string`            | the readiness to wait for: `none`, `interactive`, `complete` (default) or `networkIdle` |
| `options.timeout`<br />*optional*      | `number`            | how long to wait for the page to load, in milliseconds                                  |
| `options.onBeforeLoad`<br />*optional* | `Function`          | a function that runs in the page before its own scripts                                 |
| `options.auth`<br />*optional*         | `Object`            | basic authentication credentials, `{ user, pass }`                                      |
| `options.headers`<br />*optional*      | `Object`            | headers to send with the request                                                        |

## Example[​](#example "Direct link to Example")

navigate.js

```
it('navigates one tab without touching the other', async () => {

    const page = await browser.url('https://webdriver.io')

    const tab = await browser.newWindow('https://webdriver.io', { type: 'tab' })



    await tab.navigate('https://webdriver.io/docs/api', { wait: 'interactive' })

    console.log(tab.url) // outputs: "https://webdriver.io/docs/api"

    console.log(await page.getUrl()) // outputs: "https://webdriver.io/"

})
```

## Returns[​](#returns "Direct link to Returns")

* **\<WebdriverIO.BrowsingContext>** **`return`:** this browsing context
