t.takeScreenshot Method

Takes screenshot of the entire page. Can be chained with other TestController methods.

t.takeScreenshot([options]) → this | Promise<any>
obsolete: t.takeScreenshot([path]) → this | Promise<any>

The options object can include the following properties:

Parameter Type Description Default Value
path (optional) String The screenshot file's relative path and name. The path is relative to the root directory specified in the runner.screenshots API method or the -s (--screenshots) command line option. This property overrides the relative path specified with the default or custom path patterns.
fullPage (optional) Boolean Specifies that the full page should be captured, including content that is not visible due to overflow. false

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

import { Selector } from 'testcafe';

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

test('Take a screenshot of a fieldset', async t => {
    await t
        .typeText('#developer-name', 'Peter Parker')
        .click('#submit-button')
        .takeScreenshot({
            path:     'my-fixture/thank-you-page.png',
            fullPage: true
        });
});

You can also take a screenshot of a specified element with the t.takeElementScreenshot method.

See Screenshots and Videos for more information on taking screenshots.