t.takeScreenshot Method

Takes screenshot of the entire page.

t.takeScreenshot( [options] )
obsolete: t.takeScreenshot( [path] )

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')
            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.