Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
56 lines (36 sloc) 1.63 KB

Document with an annotated screenshot

While Selenium has built-in support for capturing whole page screenshots, usually screenshots must be cropped and some times also annotated to make them useful in a documentation.

A Robot Framework library called Selenium2Screenshots provides a collection of re-usable keywords for cropping and annotating screenshots.

A cropped and annotated screenshot could look like this:

robotframework.png
*** Settings ***

Library  Selenium2Library
Library  Selenium2Screenshots

Suite Teardown  Close all browsers

*** Variables ***

${BROWSER}  Firefox

*** Keywords ***

Highlight heading
    [Arguments]  ${locator}
    Update element style  ${locator}  margin-top  0.75em
    Highlight  ${locator}

*** Test Cases ***

Take an annotated screenshot of RobotFramework.org
    Open browser  http://robotframework.org/  browser=${BROWSER}

    Highlight heading   css=#header h1

    ${note1} =  Add pointy note
    ...    css=#header
    ...    This screenshot was generated using Robot Framework and Selenium.
    ...    width=250  position=bottom
    Capture and crop page screenshot  robotframework.png
    ...    css=#header  ${note1}

Note

The image cropping feature for robotframework-selenium2screenshots requires PIL or Pillow.

You can’t perform that action at this time.