I need to verify PDF contents, when I click on pdf print button on web page, it displays PDF to print. How can I verify? Is it possible?

2 Answers 2


Selenium does not provide any API to verify the contents of a pdf. I am not sure which language binding you are using. However every language has its own specific libraries that help you achieve parsing/extracting contents of pdf. e.g. In Java you might consider using pdfbox or iText.



  • I am Using Java
    – Ash
    Oct 9, 2018 at 10:44
  • As mentioned you can think of using apache pdfbox or itext Oct 9, 2018 at 14:26
  • Additionally, you could looking for using rest assured instead (or complementing) Selenium, since your goal is to check the response body, instead of the interaction of the browser. Oct 9, 2018 at 14:47

Capture a screenshot of PDF and compare it with expected image. Article linked here implements image comparison


Download PDF as a file and compare it with expected file. Article linked here implements Comparing Pdf files With Selenium https://seleniummaster.com/sitecontent/index.php/selenium-web-driver-menu/selenium-test-automation-with-java/165-comparing-pdf-documentations-with-selenium#:~:text=Testing%20approach%3A%20use%20Selenium%20Web,two%20packages%20as%20highlighted%20below.

Also check the link to a question Is there a way to compare content of two text files using selenium? It may not be directly relevant but may provide context on comparing two artifacts. https://stackoverflow.com/questions/56527457/is-there-a-way-to-compare-content-of-two-text-files-using-selenium

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.