Skip to main content

url

Overview

Use the url command to navigate to the specified URL in the browser.

If baseUrl is specified in the configuration, it will be added to the url parameter using the Node.js method url.resolve().

Calling browser.url() with the same URL as before will reload the page.

Usage

await browser.url(url);

Command Parameters

NameTypeDescription
urlStringThe URL to open.

Usage Examples

url.js

// navigate to URL
await browser.url("https://webdriver.io");

// get the URL
console.log(await browser.getUrl()); // outputs: "https://webdriver.io"

baseUrlResolutions.js

// Let baseUrl = http://example.com/site

// Specifying a full URL results in https://webdriver.io
await browser.url("https://webdriver.io");

// Specifying a URL without a leading slash
// results in the URL relative to the baseUrl: http://example.com/site/relative
await browser.url("relative");

// Specifying a URL with a leading slash
// results in the URL relative to the root of baseUrl: http://example.com/rootRelative
await browser.url("/rootRelative");

References

We'd like to give credit to the original WebdriverIO docs article, from which we drew some information while writing our version.