t.takeScreenshot Method
Takes screenshot of the entire page. Chainable.
t.takeScreenshot([options]) → this | Promise<any>
deprecated: t.takeScreenshot([path]) → this | Promise<any>
The options
object can include the following properties:
Parameter | Type | Description | Default Value |
---|---|---|---|
path (optional) |
String | The screenshot file’s relative path and name. The path is relative to the root directory specified in the runner.screenshots API method or the -s (--screenshots) command line option. This property overrides the relative path specified with the default or custom path patterns. | |
fullPage (optional) |
Boolean | Specifies that the full page should be captured, including content that is not visible due to overflow. | false |
Important
t.takeScreenshot requires .NET 4.0 or newer installed on Windows machines and an ICCCM/EWMH-compliant window manager on Linux.
The following example shows how to use the t.takeScreenshot
action.
fixture`TestController.takeScreenshot`
.page`https://devexpress.github.io/testcafe/example/`;
test('Take a screenshot of a fieldset', async t => {
await t
.typeText('#developer-name', 'Peter Parker')
.click('#submit-button')
.takeScreenshot({
path: 'my-fixture/thank-you-page.png',
fullPage: true,
});
});
You can also take a screenshot of a specified element with the t.takeElementScreenshot method.
See Screenshots and Videos for more information on taking screenshots.