Screenshot

Screenshot #

Since these screenshots are uploaded only after selenium script has fully exited, screenshots could be lost if test was aborted early or has failed.
client.takeScreenshot((filename: string), (exitOnFail: boolean = false));

The filename parameter specifies name of the file when it will be saved.

The exitOnFail parameter lets participant terminate test execution if there was a problem taking screenshot. This parameter can be omitted and will default to false.

function (browser) {
    // Example of taking browser screenshot
    browser
        .url('https://google.com')
        .waitForElementVisible('body', 10000)
        .takeScreenshot('screenshot.png');
}
Screenshot creation is impossible in some cases, for example, when an alert is open.