Take Screenshot

Takes a screenshot of the tested page.

Note: this action requires a ICCCM/EWMH-compliant window manager on Linux.

t.takeScreenshot( [path] )
Parameter Type Description Default
path (optional) String The relative path and the name of the screenshot file to be created. Resolved from the screenshot directory specified by using the runner.screenshots API method or the screenshots-path command line option. {currentDate}\test-{testIndex}\{userAgent}\{screenshotIndex}.png; {currentDate}\test-{testIndex}\run-{quarantineAttempt}\{userAgent}\{screenshotIndex}.png if quarantine mode is enabled.

If the screenshot directory is not specified with the runner.screenshots API method or the screenshots-path command line option, the t.takeScreenshot action is ignored.

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

fixture `My fixture`
    .page `http://www.example.com/`;

test('Take a screenshot of my new avatar', async t => {
    await t
        .click('#change-avatar')
        .setFilesToUpload('#upload-input', 'img/portrait.jpg')
        .click('#submit')
        .takeScreenshot('my-fixture/test1.png');
});