Version: | 2.7.2 |
---|---|
Scope: | test suite |
Named arguments: | supported |
A test library for taking screenshots and embedding them into log files.
Using with Jython
On Jython this library uses Java AWT APIs. They are always available and thus no external modules are needed.
Using with Python
On Python you need to have one of the following modules installed to be able to use this library. The first module that is found will be used.
Framework users already have this module installed.
Linux distributions.
This module can take screenshots only on Windows.
Python support was added in Robot Framework 2.5.5.
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 in importing and Set Screenshot Directory keyword during execution. It is also possible to save screenshots using an absolute path.
Note that prior to Robot Framework 2.5.5 the default screenshot location was system's temporary directory.
Changes in Robot Framework 2.5.5 and Robot Framework 2.6
This library was heavily enhanced in Robot Framework 2.5.5 release. The changes are listed below and explained more thoroughly in affected places.
were added. These keywords should be used for taking screenshots in the future. Other screenshot taking keywords will be deprecated and removed later.
In Robot Framework 2.6, following additional changes were made:
keywords were deprecated. They will be removed in Robot Framework 2.8.
Arguments | Documentation | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
screenshot_directory=None | Configure where screenshots are saved. If screenshot_directory is not given, screenshots are saved into same directory as the log file. The directory can also be set using Set Screenshot Directory keyword. Examples (use only one of these):
|
Keyword | Arguments | Documentation | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Log Screenshot | basename=screenshot, directory=None, width=100% | DEPRECATED Use Take Screenshot or Take Screenshot Without Embedding instead. | ||||||||||||||||||||||||
Save Screenshot | basename=screenshot, directory=None | DEPRECATED Use Take Screenshot or Take Screenshot Without Embedding instead. | ||||||||||||||||||||||||
Save Screenshot To | path | DEPRECATED Use Take Screenshot or Take Screenshot Without Embedding instead. | ||||||||||||||||||||||||
Set Screenshot Directory | path | Sets the directory where screenshots are saved. It is possible to use / as a path separator in all operating systems. Path to the old directory is returned. The directory can also be set in importing. | ||||||||||||||||||||||||
Take Screenshot | name=screenshot, width=800px | Takes a screenshot and embeds it into the log file. Name of the file where the screenshot is stored is derived from name. If name ends with extension .jpg or .jpeg, the screenshot will be stored with that name. Otherwise a unique name is created by adding underscore, a running index and extension to the name. 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. width specifies the size of the screenshot in the log file. The path where the screenshot is saved is returned. Examples: (LOGDIR is determined automatically by the library)
Screenshots can be only taken in JPEG format. It is possible to use / as a path separator in all operating systems. | ||||||||||||||||||||||||
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. |