Screenshot - Documentation

Version: 2.1.2

Introduction

A test library for taking full-screen screenshots of the desktop.

Screenshot is Robot Framework's standard library that provides keywords to capture and store screenshots of the whole desktop. This library is implemented with Java AWT APIs, so it can be used only when running Robot Framework on Jython.

Importing

Arguments Documentation
default_directory=None, log_file_directory=None Screenshot library can be imported with optional arguments.

If the default_directory is provided, all the screenshots are saved into that directory by default. Otherwise the default location is the system temporary directory.

log_file_directory is used to create relative paths when screenshots are logged. By default the paths to images in the log file are absolute.

Examples (use only one of these):

Setting Value Value Value
Library Screenshot
Library Screenshot ${CURDIR}/images
Library Screenshot ${OUTPUTDIR} ${OUTPUTDIR}

It is also possible to set these directories using Set Screenshot Directories keyword.

Shortcuts

Keywords

Keyword Arguments Documentation
Log Screenshot basename=screenshot, directory=None, log_file_directory=None, width=100% Takes a screenshot and logs it to Robot Framework's log file.

Saves the files as defined in the keyword Save Screenshot and creates a picture to Robot Framework's log. directory defines the directory where the screenshots are saved. By default, its value is default_directory, which is set at the library import or with the keyword Set Screenshot Directories. log_file_directory is used to create relative paths to the pictures. This allows moving the log and pictures to different machines and having still working pictures. If log_file_directory is not given or set (in the same way as default_directory is set), the paths are absolute.

The path where the screenshot is saved is returned.
Save Screenshot basename=screenshot, directory=None Saves a screenshot with a generated unique name.

The unique name is derived based on the provided basename and directory passed in as optional arguments. If a directory is provided, the screenshot is saved under that directory. Otherwise, the default_directory set during the library import or by the keyword Set Screenshot Directories is used. If a basename for the screenshot file is provided, a unique filename is determined by appending an underscore and a running counter. Otherwise, the basename defaults to 'screenshot'.

The path where the screenshot is saved is returned.

Examples:
Save Screenshot mypic /home/user # (1)
Save Screenshot mypic # (2)
Save Screenshot # (3)
=>
1. /home/user/mypic_1.jpg, /home/user/mypic_2.jpg, ...
2. /tmp/mypic_1.jpg, /tmp/mypic_2.jpg, ...
3. /tmp/screenshot_1.jpg, /tmp/screenshot_2.jpg, ...
Save Screenshot To path Saves a screenshot to the specified file.

The directory holding the file must exist or an exception is raised.
Set Screenshot Directories default_directory=None, log_file_directory=None Used to set default_directory and log_file_directory.

See the library importing for details.