1

I have a scenario to test where I download a PDF file from UI and compare the content of PDF with an image. This image is just a small portion of the PDF.

I am downloading the PDF using Selenium and taking the screenshot of an element and saving it as image. Is there a possible way to verify whether that image is present in PDF.

Niels van Reijmersdal
32.7k4 gold badges59 silver badges125 bronze badges
asked May 23, 2017 at 7:20

1 Answer 1

1

Selenium can only driver the browser. So after you have downloaded a file you need some other way to check its content.

The technique is called template matching, finding an image within another image.

I think you can use ImageMagick to convert the PDF to a image and then check the image contains another image.

Probably you have to make sure the image you are comparing have the same resolution...

So yes it is possible, but it won't be straightforward and easy to implement, better to ask some developers to help you. Also question yourself what are you testing? Testing with image comparing is prone to a lot of maintenance, can you trust the PDF library todo its work? Unit-test the generations behavior and just check the file is generated in the end-to-end test?

answered May 23, 2017 at 7:37

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.