savePDF
Prints the page of the current browsing context to a PDF file on your OS.
Usage
browser.savePDF(filepath, { orientation, scale, background, width, height, top, bottom, left, right, shrinkToFit, pageRanges })
Parameters
Name | Type | Details |
---|---|---|
filepath | String | path to the generated pdf (.pdf suffix is required) relative to the execution directory |
options optional | PDFPrintOptions | Print PDF Options |
options.orientation optional | String | Orientation of PDF page |
options.scale optional | number | Scale of PDF page |
options.background optional | boolean | Include background of PDF page |
options.width optional | number | Width of PDF page |
options.height optional | number | Height of PDF page |
options.top optional | number | Top padding of PDF page |
options.bottom optional | number | Bottom padding of PDF page |
options.left optional | number | Left padding of PDF page |
options.right optional | number | Right padding of PDF page |
options.shrinkToFit optional | boolean | Shrink page to fit page |
options.pageRanges optional | Array.<object> | Range of pages to include in PDF |
Example
- Asynchronous Mode
- Synchronous Mode
savePDF.js
it('should save a PDF screenshot of the browser view', function () {
await browser.savePDF('./some/path/screenshot.pdf');
});
savePDF.js
it('should save a PDF screenshot of the browser view', function () {
browser.savePDF('./some/path/screenshot.pdf');
});
caution
Synchronous Mode will depcrecated with Node.js v16. With an update to the underlying Chromium version it became technically impossible to provide the same synchronous behavior. We recommend to start transition to asynchronous command execution. For more information, see our RFC.