Member-only story
Selenium Workbook #48: Verify PDF Content
Assert text in PDF file
This article is one of the “Web Test Automation Workbook” series, a set of bite-sized exercises (typically 15–20 mins). A practical and satisfying way to learn web test automation with Selenium WebDriver.
Learning Objectives
- Verify the content of a PDF file with
pdf-reader
- Introduce third-party gems, including installation
Test Case #48
Test design
- Print an invoice (See Exercise #47)
- Verify the invoice number and total amount in the PDF matches the page.
Test Data:
Login (business): physio@biz.com
(password: test01
)
This test is easy to perform manually. A manual tester would double-click to open the downloaded PDF file. Then visually inspect it against the web page.
Automated test scripts, by default, cannot ‘read’ the PDF’s content. Selenium WebDriver is a web automation library (for non-coders, you can consider a library as a utility), we can use it to drive a browser and retrieve the source of web pages. But to retrieve a PDF document’s content, we would use help from a PDF library, pdf-reader
.