0

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?

1

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.

https://pdfbox.apache.org/

https://developers.itextpdf.com/

3
  • I am Using Java
    – Ash
    Oct 9 '18 at 10:44
  • As mentioned you can think of using apache pdfbox or itext Oct 9 '18 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 '18 at 14:47
0

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

http://automationtesting.in/image-comparison-in-selenium/#:~:text=Practically%20speaking%20image%20comparison%20is,use%20to%20compare%20two%20images.

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, privacy policy and cookie policy

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