Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | 3x 1x 2x 2x 2x | /**
*
* 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.
*
* <example>
:url.js
// navigate to a new URL
browser.url('https://webdriver.io');
// receive url
console.log(browser.getUrl()); // outputs: "https://webdriver.io"
:baseUrlResolutions.js
// With a base URL of http://example.com/site, the following url parameters resolve as such:
// When providing a scheme:
// https://webdriver.io
browser.url('https://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');
* </example>
*
* @param {String=} url the URL to navigate to
*
* @see https://w3c.github.io/webdriver/webdriver-spec.html#dfn-get
* @see https://nodejs.org/api/url.html#url_url_resolve_from_to
* @type protocol
*
*/
import nodeUrl from 'url'
import { validateUrl } from '../../utils'
export default function url (path) {
if (typeof path !== 'string') {
throw new Error('Parameter for "url" command needs to be type of string')
}
Eif (typeof this.options.baseUrl === 'string') {
path = nodeUrl.resolve(this.options.baseUrl, path)
}
return this.navigateTo(validateUrl(path))
}
|