Runner.screenshots Method

Specifies how TestCafe takes screenshots of tested pages.

screenshots(options) → this
obsolete: screenshots(path [, takeOnFails] [, pathPattern] [,fullPage] [,thumbnails]) → this

The options object can include the following properties:

OptionTypeDescriptionDefault

path (optional)

String

The base path where to save screenshots. Note that to construct a complete path to these screenshots, TestCafe uses default path patterns. Use the pathPattern property to override these patterns.

'./screenshots'

takeOnFails (optional)

Boolean

Specifies whether to take screenshots when a test fails.

false

pathPattern (optional)

String

The pattern to compose screenshot files’ relative path and name. See Path Pattern Placeholders for information about available placeholders.

fullPage (optional)

Boolean

Specifies whether to capture the full page, including content that is not visible due to overflow.

false

thumbnails (optional)

Boolean

Specifies whether to make thumbnails for captured screenshots.

true

See Screenshots for details.

Pass the disableScreenshots option to the runner.run method to disable screenshots:

runner.run({
    disableScreenshots: true
});

Related configuration file properties:

Example

runner.screenshots({
    path: 'reports/screenshots/',
    takeOnFails: true,
    pathPattern: '${DATE}_${TIME}/test-${TEST_INDEX}/${USERAGENT}/${FILE_INDEX}.png',
    fullPage: true,
    thumbnails: false
});