0% found this document useful (0 votes)
69 views3 pages

Screenshot Library Guide

This document describes a test library for taking screenshots. It can be used with Python, Jython, and IronPython. By default, screenshots are saved to the directory where the Robot Framework log file is written, but a custom location can be specified. The library provides keywords to set the screenshot directory and take screenshots, embedding them in or linking from the log.

Uploaded by

mnpawan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
69 views3 pages

Screenshot Library Guide

This document describes a test library for taking screenshots. It can be used with Python, Jython, and IronPython. By default, screenshots are saved to the directory where the Robot Framework log file is written, but a custom location can be specified. The library provides keywords to set the screenshot directory and take screenshots, embedding them in or linking from the log.

Uploaded by

mnpawan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Screenshot

Library version: 3.1.2


Library scope: test suite
Named arguments: supported

Introduction
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.

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 :: [Link] :: Required also by RIDE so many Robot Framework users already have this module installed.
PyGTK :: [Link] :: This module is available by default on most Linux distributions.
Pillow :: [Link] :: Only works on Windows. Also the original PIL package is supported.
Scrot :: [Link] :: Not used on Windows. Install with 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.

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.

Importing
Arguments Documentation
screenshot_directory=None, Configure where screenshots are saved.
screenshot_module=None
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.
screenshot_module specifies the module or tool to use when using this library on Python outside OSX.
Possible values are wxPython , PyGTK , PIL and scrot , case-insensitively. If no value is given, the first
module/tool found is used in that order. See Using with Python for more information.
Examples (use only one of these):
Setting Value Value
Library Screenshot
Library Screenshot ${TEMPDIR}
Library Screenshot screenshot_module=PyGTK

Specifying explicit screenshot module is new in Robot Framework 2.9.2.

Shortcuts
Set Screenshot Directory · Take Screenshot · Take Screenshot Without Embedding

Keywords
Keyword Arguments Documentation
Set Screenshot path Sets the directory where screenshots are saved.
Directory
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, Takes a screenshot in JPEG format and embeds it into the log file.
width=800px
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)
Take # LOGDIR/screenshot_1.jpg (index automatically
Screenshot incremented)
Take mypic # LOGDIR/mypic_1.jpg (index automatically incremented)
Screenshot
Take ${TEMPDIR}/mypic # /tmp/mypic_1.jpg (index automatically incremented)
Screenshot
Take [Link] # LOGDIR/[Link] (always uses this file)
Screenshot
Take images/[Link] 80% # Specify both name and width.
Screenshot
Take width=550px # Specify only width.
Screenshot

The path where the screenshot is saved is returned.


Take Screenshot name=screenshot Takes a screenshot and links it from the log file.
Without
Embedding 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.

Altogether 3 keywords.
Generated by Libdoc on 2019-05-24 [Link].

Screenshot
Library version: 3.1.2
Library scope: test suite
Named arguments: supported

Introduction
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.

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 :: [Link] :: Required also by RIDE so many Robot Framework users already have this module installed.
PyGTK :: [Link] :: This module is available by default on most Linux distributions.
Pillow :: [Link] :: Only works on Windows. Also the original PIL package is supported.
Scrot :: [Link] :: Not used on Windows. Install with 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.

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.

You might also like