PDF Handling
The PDF Handling feature allows you to open local PDF files directly within the automation and interact with them like on a real page. This is useful for validating generated reports, invoices, or documentation.
API Reference
openPDF
Open a PDF file to check the content inside.
await browser.openPDF("./myPDF.pdf");
PDF Handling example
await browser.openPDF("./myPDF.pdf");
let pageContent = await page.getPageText();
if (pageContent.join(" ").includes("Terms and Conditions")) {
console.log("PDF validation successful: Text found.");
} else {
console.error("PDF validation failed: Text missing.");
}
PDF Handling from page download
await browser.click("Download")
let allDownloads = await browser.listDownloads()
let file = allDownloads[0].content
await page.openPDF(file)
let pageContent = await page.getPageText();
if (pageContent.join(" ").includes("Terms and Conditions")) {
console.log("PDF validation successful: Text found.");
} else {
console.error("PDF validation failed: Text missing.");
}