Skip to main content

Robot Framework Visual Assert Library

Project description

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

VisualAssertLibrary-0.2.8.tar.gz (9.3 kB view details)

Uploaded Source

File details

Details for the file VisualAssertLibrary-0.2.8.tar.gz.

File metadata

  • Download URL: VisualAssertLibrary-0.2.8.tar.gz
  • Upload date:
  • Size: 9.3 kB
  • Tags: Source
  • Uploaded using 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

File hashes

Hashes for VisualAssertLibrary-0.2.8.tar.gz
Algorithm Hash digest
SHA256 672631c0a2c6cd5a79645b468f527ff9b8ab3c281d13dbb72c3cd717689417ad
MD5 c617f24fdb2121ad8eae27f94b1f86c2
BLAKE2b-256 39d4b9ad523d19acb35f5b301fe31e46cb547f412776d464823379e98cf088bd

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page