Python SDK for Visual Regression Tracker
Requires Python 3.10 or later. Image URLs in results need VRT server 5.0.10 or later; use 5.x of this SDK with VRT 6.0.
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, IgnoreArea
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,
# httpTimeoutInSeconds - How long to wait for the server's answer, 0 for no limit.
# The server compares images while answering track(); with VLM checks or a busy
# comparison queue that can take minutes, so keep it above 300.
httpTimeoutInSeconds=360,
)
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,
"httpTimeoutInSeconds":360
}
vrt.json is read from the current working directory.
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 \
VRT_HTTPTIMEOUTINSECONDS=360 \
python
Empty variables are ignored.
vrt = VisualRegressionTracker()
Setup / Teardown
As context manager:
with vrt:
...
# track test runs
...
Without context manager:
build = vrt.start() # Build(id, projectId)
...
# track test runs
...
vrt.stop()
Assert
result = 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
)
],
))
track returns a TestRunResult: testRunResponse (with status and the url of the test run in the
VRT app) and imageUrl, diffUrl, baselineUrl.
track raises TestRunError when the status is new (no baseline yet) or unresolved (difference found);
with enableSoftAssert it logs the error instead. ok, approved and autoApproved pass; failed passes
too, as in the JavaScript SDK. A status this SDK does not know becomes TestRunStatus.UNKNOWN.
An HTTP error from the server raises ServerError with status_code and the server's message.
A request that gets no answer (connection refused, connect timeout after 10 s, read timeout after
httpTimeoutInSeconds) raises RequestError with the url. A read timeout on track does not mean
the server dropped the test run: it may still be stored.
Integration with Microsoft Playwright
Imports
from playwright.sync_api import sync_playwright
from visual_regression_tracker import Config
from visual_regression_tracker.playwright import PlaywrightVisualRegressionTracker
Start playwright and navigate to page
playwright = sync_playwright().start()
browserType = playwright.chromium
browser = browserType.launch(headless=False)
page = browser.new_page()
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
result = 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 visible 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
result = vrt.trackElementHandle(elementHandle, imageName[, options])
The async API has trackPageAsync and trackElementHandleAsync. All four return the same TestRunResult as track.
-
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.
-
Development
pip install -e '.[playwright]' -r requirements.txt
python -m playwright install chromium
python -m pytest
Metadata
Release files for visual-regression-tracker 5.0.0
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 |
|---|---|---|---|---|
| visual_regression_tracker-5.0.0.tar.gz | 22.1 kB | With provenance | Details for visual_regression_tracker-5.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| visual_regression_tracker-5.0.0-py3-none-any.whl | Python 3 | none | any | Details for visual_regression_tracker-5.0.0-py3-none-any.whl |
Total release size: 37.3 kB
Release files / visual_regression_tracker-5.0.0.tar.gz
| Download URL | visual_regression_tracker-5.0.0.tar.gz |
|---|---|
| Size | 22.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
17e03ec42e25d84eaefcf30ea192df67f648bcdd44b1250a6ff4d9958ecc446c
|
|
BLAKE2b-256 checksum How to use checksums |
5598317f4923a098ab03f511266b3d470e1aa4fe8d583e9171bc31c17f5df6cb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 2, 2026.
Transparency logRelease files / visual_regression_tracker-5.0.0-py3-none-any.whl
| Download URL | visual_regression_tracker-5.0.0-py3-none-any.whl |
|---|---|
| Size | 15.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
24aac562c19794df4502ccd27536ceb1d7e8481eb8c3c8012942b978ca003c01
|
|
BLAKE2b-256 checksum How to use checksums |
5f0057dc46dbbc742cbca5866bc3f25361a3305e294f19e3c863b5e7ed8f837f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 2, 2026.
Transparency logSecurity for visual-regression-tracker 5.0.0
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.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for visual_regression_tracker-5.0.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 2, 2026.
Transparency logA 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.