Test.page Method

Specifies the page where the test starts.

test.page( url ) → this
test.page `url` → this
Parameter Type Description
url String The URL of the webpage at which the test starts.

You can also use the fixture.page function to specify a start page for all tests in the fixture. However, start pages set with test.page override fixture.page.

fixture`Test.page`
    .page`http://devexpress.github.io/testcafe/example`;

test.page`http://devexpress.github.io/testcafe/blog/`('My test', async () => {
    // Starts at http://devexpress.github.io/testcafe/blog/
});

If the start page is not specified, the default URL is about:blank.

You can use the file URI scheme or relative paths to test web pages in local and network directories.

test.page`file://${path.join(__dirname, './index.html')}`('My test', async () => {
    // Starts at file://${path.join(__dirname, './index.html')}
});

For local files omit the hostname:

test.page`file:///${path.join(__dirname, './index.html')}`('My test', async () => {
    // Starts at file://${path.join(__dirname, './index.html')}
});

Relative paths are resolved against a file with tests:

test.page`./index.html`('My test', async () => {
    // Starts at ../my-project/index.html
});