Robot Framework test library for taking screenshots
The library is based on RobotFramework’s standard Screenshot library. It has almost the same functionality, except that the screenshots are captured in PNG by default.
- ScreenCapLibrary has the following extra features:
- Taking screenshots in both PNG and JPG/JPEG formats
- Adjusting the compression/quality of the screenshots
Features to be implemented in the future:
- Support for GIFs
- Configurable monitor screen grabbing
- Taking multiple screenshots in a given amount of time
- Support for partial screen captures
See keyword documentation for available keywords and more information about the library in general.
For general information about using test libraries with Robot Framework, see Robot Framework User Guide.
The recommended installation method is using pip:
pip install --upgrade robotframework-screencaplibrary
Running this command installs also the latest Robot Framework, mss and pillow versions. The minimum supported mss version is 3.2.1 and the minimum supported pillow version is 5.2.0. The --upgrade option can be omitted when installing the library for the first time.
With recent versions of pip it is possible to install directly from the GitHub repository. To install latest source from the master branch, use this command:
pip install git+https://github.com/mihaiparvu/ScreenCapLibrary.git
Alternatively you can download the source distribution from PyPI, extract it, and install it:
python setup.py install
To use ScreenCapLibrary in Robot Framework tests, the library needs to first be imported using the Library setting as any other library.
When using Robot Framework, it is generally recommended to write as easy-to-understand tests as possible.
*** Settings *** Documentation This example demonstrates capturing a screenshot on the local ... machine. Library ScreenCapLibrary Library OperatingSystem Test Teardown Remove File screenshot_1.jpg *** Test Cases *** Take A Low File Size Jpg Screenshot Take Screenshot name=screenshot format=jpg quality=0 File Should Exist screenshot_1.jpg
At the time of this release mss, does not work on GNU/Linux with VNC virtual desktop. As a workaround you can change the screenshot_module value at library import to PyGTK.
*** Settings *** Library ScreenCapLibrary screenshot_module=PyGTK
For this to work you need to have the following dependencies installed.
With Python 2:
sudo apt install python-gtk2
With Python 3:
sudo apt install python-gi python-gi-cairo python3-gi python3-gi-cairo gir1.2-gtk-3.0