Runner.screenshots Method

Defines page screenshot settings.

screenshots(options) → this
deprecated: screenshots(path [, takeOnFails] [, pathPattern] [, pathPatternOnFails] [,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

Specifies a custom path pattern for TestCafe screenshots. Use placeholders to mark the path’s dynamic components.

pathPatternOnFails (optional)

String

Set the pathPatternOnFails option to define a custom naming pattern for screenshots taken on test failure. If you set both the pathPattern option and the pathPatternOnFails option, the latter takes precedence in the event of test failure.

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',
    pathPatternOnFails: '${DATE}_${TIME}/failedTests/test-${TEST_INDEX}/${USERAGENT}/${FILE_INDEX}.png',
    fullPage: true,
    thumbnails: false
});