You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The latest WebDrivers have added the print functionality from the latest W3C working draft but the js library does not have a command to use this.
Motivation
The closest functionality that exists in selenium is taking a screenshot but that does not cover all cases for printing. There are many libraries that depend on selenium specifically for saving the html as pdf but do not use the latest WebDrivers. This will save all those developers from needing to create alternate libraries and avoid bugs.
Great! This can be done with current library by adding this code:
import command from 'selenium-webdriver/lib/command');
// This function only needs to be done once for the driver
function addPrintCommand(driver) {
const executor = driver.getExecutor();
executor.defineCommand('print', 'POST', '/session/:sessionId/print');
}
function printToPdf(printOptions) {
const pdfBase64 = await driver.execute(new command.Command('print').setParameters(printOptions));
return Buffer.from(pdfBase64, 'base64');
}
Thought I'd leave this here for anyone stumbling upon it before release.
🚀 Feature Proposal
The latest WebDrivers have added the print functionality from the latest W3C working draft but the js library does not have a command to use this.
Motivation
The closest functionality that exists in selenium is taking a screenshot but that does not cover all cases for printing. There are many libraries that depend on selenium specifically for saving the html as pdf but do not use the latest WebDrivers. This will save all those developers from needing to create alternate libraries and avoid bugs.
Example
The text was updated successfully, but these errors were encountered: