# DocTestLibrary - A Library for Visual Document Testing (and more)

**URL:** <https://forum.robotframework.org/t/doctestlibrary-a-library-for-visual-document-testing-and-more/1442>\
**Category:** Libraries\
**Created:** [9 March 2021 20:34 UTC](https://forum.robotframework.org/t/doctestlibrary-a-library-for-visual-document-testing-and-more/1442 "2021-03-09T20:34:37Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Many](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/many/32/658_2.png) [@Many](https://forum.robotframework.org/u/Many)\
**Post date:** [9 March 2021 20:34 UTC](https://forum.robotframework.org/t/doctestlibrary-a-library-for-visual-document-testing-and-more/1442/1 "2021-03-09T20:34:37Z")

</div>

Hey everyone,

I would like to share a new Robot Framework Library with you, that I just released.

> **[manykarim/robotframework-doctestlibrary](https://github.com/manykarim/robotframework-doctestlibrary)**
>
> Contribute to manykarim/robotframework-doctestlibrary development by creating an account on GitHub.

> **[robotframework-doctestlibrary](https://pypi.org/project/robotframework-doctestlibrary/)**

It’s a library for visual document testing and the concept is pretty simple:  
It loads two documents (e.g. PDF files) and compares them visually.  
If they are equal - passed. If they differ - failed.

We use it in our company to test our central output management system after a new release.  
To make sure that changes don’t have any “unwanted” effects on the generated outputs.

It has some useful features, like masking parts of the document (pased on text patterns or position) or even accepting small visual differents (like moved areas/texts within a defined range).

It can also check some properties of .pcl and .postscript files, but I guess that’s a very ‘specific’ functionality for our company.

It has a LOT of dependencies (like OpenCV, Tesseract, PyWand, …) so I definitely recommend to install it in a virtual python environment.

Some binaries need to be installed separately (Tesseract-OCR, ImageMagick, Ghostscript, …) but it’s all described in the ReadMe.  
A Docker Image will also be provided, until then feel free to build your own container using the included Dockerfile.

It’s still in a very early stage, but the basic functionality (simple comparisons with masks) is working in a reliable way.

It will be presented in my talk at RoboCon 2021  
[https://robocon.io/#print-is-(not)-dead-–-visual-document-testing-using-robot-framework](https://robocon.io/#print-is-(not)-dead-%E2%80%93-visual-document-testing-using-robot-framework)

Looking forward to hearing your feedback 😃

---

<div class="post-metadata">

**Author:** ![Ptr](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/ptr/32/4216_2.png) [@Ptr](https://forum.robotframework.org/u/Ptr)\
**Post date:** [10 September 2024 10:45 UTC](https://forum.robotframework.org/t/doctestlibrary-a-library-for-visual-document-testing-and-more/1442/2 "2024-09-10T10:45:50Z")

</div>

Hi,

I’m facing an issue when i do “Compare Images” call in RF using doctestlibrary.  
I need to run the comparison like this

`Compare Images ${REFERENCE_DIR}/${filename} ${CANDIDATE_DIR}/${filename} resize_candidate=True blur=True placeholder_file=${MASK_DIR}/${mask}`

As you might see, the reference file and the candidate will be of different resolution. The problem i’m facing with this is, that the Mask is not resized/converted correctly for the candidate file and thus this kind of combination seems impossible to achieve with Compare Images keyword atm.

Is this a bug, i would really need this. The problem lies in the fact that i make the tests locally on my laptop which eventually has different resolution compared to when i run the tests in Azure pipeline. I run the tests headlesschorme and set the browser window size staticly  
`Set Window Size 1920 1080`  
but still the images i get locally are over 1920x1080 in resolution while the azure pipeline images are 1904x933 in size.

---

<div class="post-metadata">

**Author:** ![Many](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/many/32/658_2.png) [@Many](https://forum.robotframework.org/u/Many)\
**Post date:** [10 September 2024 10:59 UTC](https://forum.robotframework.org/t/doctestlibrary-a-library-for-visual-document-testing-and-more/1442/3 "2024-09-10T10:59:12Z")

</div>

Hi Peter,

Thats an interesting constellation.  
The expectation is, that the mask is scaled in the same factor as the candidate file is scaled to the reference image, correct?  
I think that should be simple to implement.  
Will you support the testing of that change?

---

<div class="post-metadata">

**Author:** ![Ptr](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/ptr/32/4216_2.png) [@Ptr](https://forum.robotframework.org/u/Ptr)\
**Post date:** [10 September 2024 11:12 UTC](https://forum.robotframework.org/t/doctestlibrary-a-library-for-visual-document-testing-and-more/1442/4 "2024-09-10T11:12:28Z")

</div>

Yes, im happy to test it out.

---

<div class="post-metadata">

**Author:** ![Many](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/many/32/658_2.png) [@Many](https://forum.robotframework.org/u/Many)\
**Post date:** [11 September 2024 20:36 UTC](https://forum.robotframework.org/t/doctestlibrary-a-library-for-visual-document-testing-and-more/1442/5 "2024-09-11T20:36:10Z")

</div>

ok, I’m working on it and I realized that I made a silly design decision which makes this change a little bit harder to implement than it should be.  
But I should have a prerelase soon that you can try.

I created the following issue to track this topic

> <https://github.com/manykarim/robotframework-doctestlibrary/issues/99>
>
> Currently, when two images of different sizes are compared (with resize\_candidat…e=True) the masks/placeholders are not resized in the same way as the image. The reason is that the image with the masked areas is generated before the resize operation. 
> That should be changed.
> First, the resizing if candidate image should happen and AFTERWARDS the mask should be applied

---

<div class="post-metadata">

**Author:** ![Many](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/many/32/658_2.png) [@Many](https://forum.robotframework.org/u/Many)\
**Post date:** [11 September 2024 21:34 UTC](https://forum.robotframework.org/t/doctestlibrary-a-library-for-visual-document-testing-and-more/1442/6 "2024-09-11T21:34:11Z")

</div>

I created a prerelease `0.23.0dev0`

You can install it via  
`pip install --pre --upgrade robotframework-doctestlibrary`

The images are now resized before applying the mask.  
This works only, with the argument `resize_candidate=True`

Pleae give it a try and give me a feedback in the GitHub issue.  
Thanks a lot.
