savePDF
Overview
Use the savePDF
command to save the current browser context to a PDF file.
Usage
await browser.savePDF(filepath, {
orientation,
scale,
background,
width,
height,
top,
bottom,
left,
right,
shrinkToFit,
pageRanges,
});
Command Parameters
Name | Type | Description |
filepath | String | Path to the PDF file relative to the execution directory (the .pdf extension is mandatory). |
orientation | String | Orientation of the PDF page. |
scale | Number | Scale of the PDF page. |
background | Boolean | Include the background in the PDF. |
width | Number | Width of the PDF page. |
height | Number | Height of the PDF page. |
top | Number | Top margin of the PDF page. |
bottom | Number | Bottom margin of the PDF page. |
left | Number | Left margin of the PDF page. |
right | Number | Right margin of the PDF page. |
shrinkToFit | Number | Shrink the page to fit the PDF page size. |
pageRanges | Object[] | Range of pages to include in the PDF. |
Usage Examples
it("should save a PDF screenshot of the browser view", async ({ browser }) => {
await browser.savePDF("./some/path/screenshot.pdf");
});
Related Commands
References
We'd like to give credit to the original WebdriverIO docs article, from which we drew some information while writing our version.