# getUrl

Get the URL of the document shown in this browsing context, read from the page. It also updates the `url` property, which otherwise holds the URL the context was last navigated to and does not follow navigations the page did itself.

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

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

await context.getUrl()
```

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

getUrl.js

```
it('reads the url after the page changed it', async () => {

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

    await page.execute(() => history.pushState({}, '', '/docs/api'))



    console.log(page.url) // outputs: "https://webdriver.io", the url it was navigated to

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

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

})
```

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

* **\<string>** **`return`:** the document URL
