Python SDK for Visual Regression Tracker
Install
pip install visual-regression-tracker
# or, with playwright integration
pip install visual-regression-tracker[playwright]
python -m playwright install
Usage
Import
from visual_regression_tracker import VisualRegressionTracker, Config, TestRun
Configure connection
As python
config = Config(
# apiUrl - URL where backend is running
apiUrl='http://localhost:4200',
# project - Project name or ID
project='Default project',
# apiKey - User apiKey
apiKey='tXZVHX0EA4YQM1MGDD',
# ciBuildId - Current git commit SHA
ciBuildId='commit_sha',
# branch - Current git branch
branchName='develop',
# enableSoftAssert - Log errors instead of exceptions
enableSoftAssert=False,
)
vrt = VisualRegressionTracker(config)
Or, as JSON config file vrt.json
{
"apiUrl":"http://localhost:4200",
"project":"Default project",
"apiKey":"tXZVHX0EA4YQM1MGDD",
"ciBuildId":"commit_sha",
"branchName":"develop",
"enableSoftAssert":false
}
vrt = VisualRegressionTracker()
Or, as environment variables
VRT_APIURL="http://localhost:4200" \
VRT_PROJECT="Default project" \
VRT_APIKEY="tXZVHX0EA4YQM1MGDD" \
VRT_CIBUILDID="commit_sha" \
VRT_BRANCHNAME="develop" \
VRT_ENABLESOFTASSERT=true \
python
vrt = VisualRegressionTracker()
Setup / Teardown
As context manager:
with vrt:
...
# track test runs
...
Without context manager:
vrt.start()
...
# track test runs
...
vrt.stop()
Assert
vrt.track(TestRun(
# Name to be displayed
# Required
name='Image name',
# Base64 encoded string
# Required
imageBase64=image,
# Allowed mismatch tollerance in %
# Optional
# Default: 0%
diffTollerancePercent=1,
# Optional
os='Mac',
# Optional
browser='Chrome',
# Optional
viewport='800x600',
# Optional
device='PC',
# Array of areas to be ignored
ignoreAreas=[
IgnoreArea(
# X-coordinate relative of left upper corner
# Required
x=10,
# Y-coordinate relative of left upper corner
# Required
y=20,
# Area width in px
# Required
width=300,
# Height width in px
# Required
height=400
)
],
))
Integration with Microsoft Playwright
Imports
from playwright import sync_playwright
from visual_regression_tracker import Config, TestRun
from visual_regression_tracker.p import PlaywrightVisualRegressionTracker
Start playwright and navigate to page
playwright = sync_playwright().start()
browserType = playwright.chromium
browser = browserType.launch(headless=False)
page = browser.newPage()
page.goto('https://www.python.org/')
Configure connection to VRT server
vrt = PlaywrightVisualRegressionTracker(browserType, config)
Setup / Tear down
As context manager:
with vrt:
...
# track test runs
...
Without context manager:
vrt.start()
...
# track test runs
...
vrt.stop()
Track page
vrt.trackPage(page, imageName[, options])
-
page: PagePlaywright page -
imageName: strname for the taken screenshot image -
options: PageTrackOptionsoptional configuration with:-
diffTollerancePercent: floatspecify acceptable difference from baseline, between0-100. -
ignoreAreas: List[IgnoreArea]x: intX-coordinate relative of left upper cornery: intY-coordinate relative of left upper cornerwidth: intarea width in pxheight: intarea height in px
-
screenshotOptions: PageScreenshotOptionsconfiguration for Playwrightsscreenshotmethod-
full_page: boolWhen true, takes a screenshot of the full scrollable page, instead of the currently visibvle viewport. Defaults tofalse. -
omit_background: boolHides default white background and allows capturing screenshots with transparency. Defaults tofalse. -
clip: FloatRectAn object which specifies clipping of the resulting image. Should have the following fields:x: floatx-coordinate of top-left corner of clip areay: floaty-coordinate of top-left corner of clip areawidth: floatwidth of clipping areaheight: floatheight of clipping area
-
timeout: floatMaximum time in milliseconds, defaults to 30 seconds, pass 0 to disable timeout.
-
-
agent: AgentAdditional information to mark baseline across agents that have different:os: stroperating system name, like Windows, Mac, etc.device: strdevice name, PC identifier, mobile identifier etc.viewport: strviewport size.
-
Track element handle
vrt.trackElementHandle(elementHandle, imageName[, options])
-
elementHandle: ElementHandlePlaywright ElementHandle -
imageName: strname for the taken screenshot image -
options: ElementHandleTrackOptionsoptional configuration with:-
diffTollerancePercent: floatspecify acceptable difference from baseline, between0-100. -
ignoreAreas: List[IgnoreArea]x: intX-coordinate relative of left upper cornery: intY-coordinate relative of left upper cornerwidth: intarea width in pxheight: intarea height in px
-
screenshotOptions: ElementHandleScreenshotOptionsconfiguration for Playwrightsscreenshotmethod-
omit_background: boolHides default white background and allows capturing screenshots with transparency. Defaults tofalse. -
timeout: floatMaximum time in milliseconds, defaults to 30 seconds, pass 0 to disable timeout.
-
-
agent: AgentAdditional information to mark baseline across agents that have different:os: stroperating system name, like Windows, Mac, etc.device: strdevice name, PC identifier, mobile identifier etc.viewport: strviewport size.
-
Metadata
Release files for bmx-visual-regression-tracker 4.9.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| bmx_visual_regression_tracker-4.9.1.tar.gz | 16.4 kB | Without provenance | Details for bmx_visual_regression_tracker-4.9.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| bmx_visual_regression_tracker-4.9.1-py2.py3-none-any.whl | Python 2, Python 3 | none | any | Details for bmx_visual_regression_tracker-4.9.1-py2.py3-none-any.whl |
Total release size: 30.2 kB
Release files / bmx_visual_regression_tracker-4.9.1.tar.gz
| Download URL | bmx_visual_regression_tracker-4.9.1.tar.gz |
|---|---|
| Size | 16.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ec7ca4297108ad5ce3c279a79de08a8cbfa6180f61519ddd91c78dede0dda61c
|
|
BLAKE2b-256 checksum How to use checksums |
4670fe910e6175a8bcd0680ba190755362036728ad703dd0e0863286f2e4648e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.9
|
Release files / bmx_visual_regression_tracker-4.9.1-py2.py3-none-any.whl
| Download URL | bmx_visual_regression_tracker-4.9.1-py2.py3-none-any.whl |
|---|---|
| Size | 13.8 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
1c36ca2b41a1038ad1cbb8f83bc79e0e935d4ad125d3ca08aff360e79d8bdabe
|
|
BLAKE2b-256 checksum How to use checksums |
aa9c0042d97e4ed059092bd08081a61eee91dac5fea7ae58a03948d74daa6b29
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.9
|
Security for bmx-visual-regression-tracker 4.9.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.