t.takeScreenshot Method

Takes screenshot of the entire page. Chainable.

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

The options object can include the following properties:

Parameter Type Description Default Value
path (optional) String Relative path to the screenshot file. Use the runner.screenshots method or the -s (--screenshots) CLI option to set the root directory. Overrides screenshot path patterns.
pathPattern (optional) String Defines a custom naming pattern for the screenshot file. See Screenshot and Video Storage Configuration.
fullPage (optional) Boolean Enable fullPage to capture the entire page, including the area outside the viewport. false

Important

t.takeScreenshot requires .NET v4.0 or higher on Windows machines and an ICCCM/EWMH-compliant window manager on Linux.

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

fixture`TestController.takeScreenshot`
    .page`https://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,
        });
});

To take a screenshot of a specific element, use the t.takeElementScreenshot method.

See Screenshots and Videos for more information on taking screenshots.