t.navigateTo Method

Navigates to the specified URL. Chainable.

t.navigateTo(url) → this | Promise<any>
Parameter Type Description
url String The URL to navigate to. Absolute or relative to the current page.

The following example shows how to use the t.navigateTo action.

fixture`TestController.navigateTo`
    .page`https://devexpress.github.io/testcafe`;

test('Navigate to the Docs', async t => {
    await t
        .navigateTo('https://devexpress.github.io/testcafe/documentation/');
});

You can use the file:// scheme or relative paths to navigate to a webpage in a local directory. Relative file paths are resolved from the current page, rather than the test file.

fixture`TestController.navigateTo`
    .page`https://devexpress.github.io/testcafe`;

test('Navigate to local pages', async t => {
    await t
        .navigateTo(`file:///${path.join(__dirname, './index.html')}`)
        .navigateTo('./index.html');
});

TestCafe waits for the server to respond after a redirect occurs. The test resumes if the server does not respond within 15 seconds.