url

Protocol binding to load or get the URL of the browser. If a baseUrl is specified in the config, it will be prepended to the url parameter using node’s url.resolve() method.

Usage

1
browser.url([url]);

Parameters

Param Type Details
url
optional
String the URL to navigate to

Example

url.js
1
2
3
4
// navigate to a new URL
browser.url('http://webdriver.io');
// receive url
console.log(browser.getUrl()); // outputs: "http://webdriver.io"
baseUrlResolutions.js
1
2
3
4
5
6
7
8
9
10
// With a base URL of http://example.com/site, the following url parameters resolve as such:
// When providing a scheme:
// http://webdriver.io
browser.url('http://webdriver.io');
// When not starting with a slash, the URL resolves relative to the baseUrl
// http://example.com/site/relative
browser.url('relative');
// When starting with a slash, the URL resolves relative to the root path of the baseUrl
// http://example.com/rootRelative
browser.url('/rootRelative');

Returns

  • <String>: the current URL