Skip to main content

Visual Assert Library

Robot Framework library for visual verification in selenium tests.

This library allows easy way for visual regression verifications in selenium based tests in Robot Framework.

How it Works

The main idea is to compare the screenshot of a rendered web page or web element against known good screenshots with expected result.

In other words, this tool follows these steps:

  • It takes a screenshot of the current web page or needed element on the page.

  • If a previous capture of this element exists in the baseline, it compares the current screenshot (actual result) with the previous one (actual result). If these screenshots differ, test fails with embedded picture showing their differences.

  • If not, the screenshot is saved to the baseline to be used as expected results in later executions. Probably this new image might be reviewed manually.

At the moment mega.nz is used to store baseline with screenshots.

Installation

python3 -m venv /path/to/virtual/environment

source /path/to/virtual/environment/bin/activate

pip install VisualAssertLibrary

Usage

*** Settings ***
Library    SeleniumLibrary
Library    VisualAssertLibrary

*** Variables ***
# In case of use mega.nz to store baseline of screenshots
${MEGA_BASELINE_DIR_NAME} =    Name of the directory
${MEGA_EMAIL} = XXXXXXX
${MEGA_PASSW} = YYYYYYY


*** Test Cases ***
Example of test
    open browser   https://some.test.site.com/some/page     Chrome
    set window size   1366   769
    Visual assert  Review has got 3 stars         # Text explaining verification. As well this text will be in the report in a case of test failure.
    ...  //*[@class="some_class"]                 # XPATH locator to the element on the which should be captured
    ...  file_name_with_expected_result.png       # File name of the screenshot with expected result.
    ...  exclude=//*[@class="to_be_excluded"]     # XPATH locator to the element to be excluded from the screenshot.

*** Keywords ***
Visual assert
    [Arguments]  @{varargs}  &{named}
    run keyword and continue on failure   assert screenshot     @{varargs}  &{named}
    ...    cols=30  rows=30  # Number of columns and rows the screenshot area should be divided (optional parameter, default is 20)
    ...    factor=1000  Empiric parameter for accuracy of comparing images (optional parameter, default is 1000)
    ...    trim=3  # Number of pixels to be removed from the top/bottom/left/right of the screenshot (optional, default is 0)

WARRANTY

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Release files for VisualAssertLibrary 0.2.8

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for VisualAssertLibrary 0.2.8
File Size Uploaded
VisualAssertLibrary-0.2.8.tar.gz 9.3 kB Details

Release files / VisualAssertLibrary-0.2.8.tar.gz

Download URL VisualAssertLibrary-0.2.8.tar.gz
Size 9.3 kB
Tags Source
SHA-256 checksum
How to use checksums
672631c0a2c6cd5a79645b468f527ff9b8ab3c281d13dbb72c3cd717689417ad
BLAKE2b-256 checksum
How to use checksums
39d4b9ad523d19acb35f5b301fe31e46cb547f412776d464823379e98cf088bd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.6.9

Release history Release notifications | RSS feed

This release

0.2.8 This release

1 release file

0.2.5

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page