Test library for taking screenshots on the machine where tests are run.
Notice that successfully taking screenshots requires tests to be run with a physical or virtual display.
Table of contents
- Using with Python
- Using with Jython and IronPython
- Where screenshots are saved
Using with Python
How screenshots are taken when using Python depends on the operating system. On OSX screenshots are taken using the built-in
screencapture utility. On other operating systems you need to have one of the following tools or Python modules installed. You can specify the tool/module to use when importing the library. If no tool or module is specified, the first one found will be used.
- wxPython :: http://wxpython.org :: Required also by RIDE so many Robot Framework users already have this module installed.
- PyGTK :: http://pygtk.org :: This module is available by default on most Linux distributions.
- Pillow :: http://python-pillow.github.io :: Only works on Windows. Also the original PIL package is supported.
- Scrot :: http://en.wikipedia.org/wiki/Scrot :: Not used on Windows. Install with
apt-get install scrotor similar.
screencapture on OSX and specifying explicit screenshot module are new in Robot Framework 2.9.2. The support for using
scrot is new in Robot Framework 3.0.
Using with Jython and IronPython
With Jython and IronPython this library uses APIs provided by JVM and .NET platforms, respectively. These APIs are always available and thus no external modules are needed.
Where screenshots are saved
By default screenshots are saved into the same directory where the Robot Framework log file is written. If no log is created, screenshots are saved into the directory where the XML output file is written.
It is possible to specify a custom location for screenshots using
screenshot_directory argument when importing the library and using Set Screenshot Directory keyword during execution. It is also possible to save screenshots using an absolute path.
ScreenCapLibrary is an external Robot Framework library that can be used as an alternative, which additionally provides support for multiple formats, adjusting the quality, using GIFs and video capturing.