Navigate to a new URL. This method will also call the onBrowserNavigate() test global, right after the page is loaded.

Usage

                    .navigateTo(url, [callback])
                

Example

describe('Navigation commands demo', function() {
  test('demoTest', function(browser) {
    // navigate to new url:
    browser.navigateTo('https://nightwatchjs.org');

    // Retrieve to url with callback:
    browser.getCurrentUrl(function(result) {
      console.log(result.value);
    });
  });

  test('demoTestAsync', async function(browser) {
    const currentUrl = await browser.navigateTo('https://nightwatchjs.org').getCurrentUrl();
    console.log('currentUrl:', currentUrl); // will print 'https://nightwatchjs.org'
  });

});

Parameters

Name Type description
url string

The url to navigate to

callback
Optional
Function

W3C WebDriver spec