Take Screenshot

Takes a screenshot of the tested page.

t.takeScreenshot( [path] )
Parameter Type Description Default
path (optional) String A relative path to the folder where screenshots should be saved. Resolved from the screenshot directory specified by using the runner.screenshots API method or the screenshots-path command line option. The screenshot directory specified by using runner.screenshots or screenshots-path.

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();
});