Test.page Method

Specifies the test’s starting URL.

Note

The test.page method overrides all other test page URL definitions.

test.page( url ) → this
test.page `url` → this
Parameter Type Description
url String The starting URL of the test, absolute or relative to the baseUrl.

Absolute URL Example

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/
});

Use the file:// URI scheme to test locally stored web pages.

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

Relative URL Example

If you set a suite-wide base URL, you can define a relative starting URL for the test. Relative URLs begin with the period character (.).

For example, if your configuration file contains the following declaration:

    "baseUrl": "https://devexpress.github.io/testcafe"

You can define a custom test URL as such:

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

URL conflicts

  • All tests start at about:blank unless you specify a different starting URL.
  • The base URL option defines the starting URL for your entire test suite.
  • A fixture URL overrides the base URL for a particular fixture.
  • A test URL overrides the fixture URL for a particular test.