Library version: | 2.8.7 |
---|---|
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.
This library was heavily enhanced in Robot Framework 2.5.5 release. Old keywords for taking screenshots were deprecated and they have since been removed.
With 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.
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.
IronPython support was added in Robot Framework 2.7.5.
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.
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 | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
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 in JPEG format and embeds it into the log file. Name of the file where the screenshot is stored is derived from the given name. If the name ends with extension .jpg or .jpeg, the screenshot will be stored with that exact name. Otherwise a unique name is created by adding an underscore, a running index and an 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. Using / as a path separator works in all operating systems. width specifies the size of the screenshot in the log file. 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. |