Library version: | 3.0.2 |
---|---|
Library scope: | test suite |
Named arguments: | supported |
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.
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.
apt-get install scrot
or similar.Using 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.
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.
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.
Arguments | Documentation | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
screenshot_directory=None, screenshot_module=None | Configure where screenshots are saved. If
Examples (use only one of these):
Specifying explicit screenshot module is new in Robot Framework 2.9.2. |
Keyword | Arguments | Documentation | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Set Screenshot Directory | path | Sets the directory where screenshots are saved. It is possible to use The directory can also be set in importing. | ||||||||||||||||||||||||
Take Screenshot | name=screenshot, width=800px | Takes a screenshot in JPEG format and embeds it into the log file. Name of the file where the screenshot is stored is derived from the given The name will be interpreted to be relative to the directory where the log file is written. It is also possible to use absolute paths. Using
Examples: (LOGDIR is determined automatically by the library)
The path where the screenshot is saved is returned. | ||||||||||||||||||||||||
Take Screenshot Without Embedding | name=screenshot | Takes a screenshot and links it from the log file. This keyword is otherwise identical to Take Screenshot but the saved screenshot is not embedded into the log file. The screenshot is linked so it is nevertheless easily available. |