visual-regression-tracker 4.8.0__tar.gz → 5.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- visual_regression_tracker-5.0.0/PKG-INFO +312 -0
- {visual_regression_tracker-4.8.0 → visual_regression_tracker-5.0.0}/README.md +49 -15
- visual_regression_tracker-5.0.0/pyproject.toml +41 -0
- visual_regression_tracker-5.0.0/setup.cfg +4 -0
- visual_regression_tracker-5.0.0/tests/test_config.py +199 -0
- visual_regression_tracker-5.0.0/tests/test_playwright.py +218 -0
- visual_regression_tracker-5.0.0/tests/test_playwright_async.py +191 -0
- visual_regression_tracker-5.0.0/tests/test_types.py +115 -0
- visual_regression_tracker-5.0.0/tests/test_visualRegressionTracker.py +412 -0
- {visual_regression_tracker-4.8.0 → visual_regression_tracker-5.0.0}/visual_regression_tracker/__init__.py +5 -2
- {visual_regression_tracker-4.8.0 → visual_regression_tracker-5.0.0}/visual_regression_tracker/config.py +26 -21
- visual_regression_tracker-5.0.0/visual_regression_tracker/exceptions.py +49 -0
- {visual_regression_tracker-4.8.0 → visual_regression_tracker-5.0.0}/visual_regression_tracker/playwright.py +5 -6
- {visual_regression_tracker-4.8.0 → visual_regression_tracker-5.0.0}/visual_regression_tracker/types.py +14 -4
- {visual_regression_tracker-4.8.0 → visual_regression_tracker-5.0.0}/visual_regression_tracker/visualRegressionTracker.py +56 -40
- visual_regression_tracker-5.0.0/visual_regression_tracker.egg-info/PKG-INFO +312 -0
- {visual_regression_tracker-4.8.0 → visual_regression_tracker-5.0.0}/visual_regression_tracker.egg-info/SOURCES.txt +6 -2
- visual_regression_tracker-5.0.0/visual_regression_tracker.egg-info/requires.txt +5 -0
- visual_regression_tracker-4.8.0/PKG-INFO +0 -266
- visual_regression_tracker-4.8.0/setup.cfg +0 -14
- visual_regression_tracker-4.8.0/setup.py +0 -23
- visual_regression_tracker-4.8.0/visual_regression_tracker/exceptions.py +0 -32
- visual_regression_tracker-4.8.0/visual_regression_tracker.egg-info/PKG-INFO +0 -266
- visual_regression_tracker-4.8.0/visual_regression_tracker.egg-info/requires.txt +0 -8
- {visual_regression_tracker-4.8.0 → visual_regression_tracker-5.0.0}/LICENSE +0 -0
- {visual_regression_tracker-4.8.0 → visual_regression_tracker-5.0.0}/visual_regression_tracker.egg-info/dependency_links.txt +0 -0
- {visual_regression_tracker-4.8.0 → visual_regression_tracker-5.0.0}/visual_regression_tracker.egg-info/top_level.txt +0 -0
|
@@ -0,0 +1,312 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: visual_regression_tracker
|
|
3
|
+
Version: 5.0.0
|
|
4
|
+
Summary: Open source, self hosted solution for visual testing and managing results of visual testing.
|
|
5
|
+
License-Expression: Apache-2.0
|
|
6
|
+
Project-URL: Homepage, https://github.com/Visual-Regression-Tracker/Visual-Regression-Tracker
|
|
7
|
+
Project-URL: Source, https://github.com/Visual-Regression-Tracker/sdk-python
|
|
8
|
+
Project-URL: Issues, https://github.com/Visual-Regression-Tracker/sdk-python/issues
|
|
9
|
+
Classifier: Programming Language :: Python :: 3
|
|
10
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
15
|
+
Classifier: Topic :: Software Development :: Testing
|
|
16
|
+
Requires-Python: >=3.10
|
|
17
|
+
Description-Content-Type: text/markdown
|
|
18
|
+
License-File: LICENSE
|
|
19
|
+
Requires-Dist: requests>=2.32.4
|
|
20
|
+
Requires-Dist: dacite>=1.9
|
|
21
|
+
Provides-Extra: playwright
|
|
22
|
+
Requires-Dist: playwright>=1.50; extra == "playwright"
|
|
23
|
+
Dynamic: license-file
|
|
24
|
+
|
|
25
|
+
# Python SDK for [Visual Regression Tracker](https://github.com/Visual-Regression-Tracker/Visual-Regression-Tracker)
|
|
26
|
+
|
|
27
|
+
[](https://www.codacy.com/gh/Visual-Regression-Tracker/sdk-python?utm_source=github.com&utm_medium=referral&utm_content=Visual-Regression-Tracker/sdk-python&utm_campaign=Badge_Grade)
|
|
28
|
+
[](https://www.codacy.com/gh/Visual-Regression-Tracker/sdk-python?utm_source=github.com&utm_medium=referral&utm_content=Visual-Regression-Tracker/sdk-python&utm_campaign=Badge_Coverage)
|
|
29
|
+
|
|
30
|
+
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.
|
|
31
|
+
|
|
32
|
+
## Install
|
|
33
|
+
|
|
34
|
+
```sh
|
|
35
|
+
pip install visual-regression-tracker
|
|
36
|
+
|
|
37
|
+
# or, with playwright integration
|
|
38
|
+
pip install "visual-regression-tracker[playwright]"
|
|
39
|
+
python -m playwright install
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Usage
|
|
43
|
+
|
|
44
|
+
### Import
|
|
45
|
+
|
|
46
|
+
```python
|
|
47
|
+
from visual_regression_tracker import VisualRegressionTracker, Config, TestRun, IgnoreArea
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### Configure connection
|
|
51
|
+
|
|
52
|
+
#### As python
|
|
53
|
+
```python
|
|
54
|
+
config = Config(
|
|
55
|
+
# apiUrl - URL where backend is running
|
|
56
|
+
apiUrl='http://localhost:4200',
|
|
57
|
+
|
|
58
|
+
# project - Project name or ID
|
|
59
|
+
project='Default project',
|
|
60
|
+
|
|
61
|
+
# apiKey - User apiKey
|
|
62
|
+
apiKey='tXZVHX0EA4YQM1MGDD',
|
|
63
|
+
|
|
64
|
+
# ciBuildId - Current git commit SHA
|
|
65
|
+
ciBuildId='commit_sha',
|
|
66
|
+
|
|
67
|
+
# branch - Current git branch
|
|
68
|
+
branchName='develop',
|
|
69
|
+
|
|
70
|
+
# enableSoftAssert - Log errors instead of exceptions
|
|
71
|
+
enableSoftAssert=False,
|
|
72
|
+
|
|
73
|
+
# httpTimeoutInSeconds - How long to wait for the server's answer, 0 for no limit.
|
|
74
|
+
# The server compares images while answering track(); with VLM checks or a busy
|
|
75
|
+
# comparison queue that can take minutes, so keep it above 300.
|
|
76
|
+
httpTimeoutInSeconds=360,
|
|
77
|
+
)
|
|
78
|
+
|
|
79
|
+
vrt = VisualRegressionTracker(config)
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
#### Or, as JSON config file `vrt.json`
|
|
83
|
+
```json
|
|
84
|
+
{
|
|
85
|
+
"apiUrl":"http://localhost:4200",
|
|
86
|
+
"project":"Default project",
|
|
87
|
+
"apiKey":"tXZVHX0EA4YQM1MGDD",
|
|
88
|
+
"ciBuildId":"commit_sha",
|
|
89
|
+
"branchName":"develop",
|
|
90
|
+
"enableSoftAssert":false,
|
|
91
|
+
"httpTimeoutInSeconds":360
|
|
92
|
+
}
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
`vrt.json` is read from the current working directory.
|
|
96
|
+
```python
|
|
97
|
+
vrt = VisualRegressionTracker()
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
#### Or, as environment variables
|
|
101
|
+
```sh
|
|
102
|
+
VRT_APIURL="http://localhost:4200" \
|
|
103
|
+
VRT_PROJECT="Default project" \
|
|
104
|
+
VRT_APIKEY="tXZVHX0EA4YQM1MGDD" \
|
|
105
|
+
VRT_CIBUILDID="commit_sha" \
|
|
106
|
+
VRT_BRANCHNAME="develop" \
|
|
107
|
+
VRT_ENABLESOFTASSERT=true \
|
|
108
|
+
VRT_HTTPTIMEOUTINSECONDS=360 \
|
|
109
|
+
python
|
|
110
|
+
```
|
|
111
|
+
Empty variables are ignored.
|
|
112
|
+
```python
|
|
113
|
+
vrt = VisualRegressionTracker()
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
### Setup / Teardown
|
|
117
|
+
|
|
118
|
+
As context manager:
|
|
119
|
+
```python
|
|
120
|
+
with vrt:
|
|
121
|
+
...
|
|
122
|
+
# track test runs
|
|
123
|
+
...
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
Without context manager:
|
|
127
|
+
```python
|
|
128
|
+
build = vrt.start() # Build(id, projectId)
|
|
129
|
+
...
|
|
130
|
+
# track test runs
|
|
131
|
+
...
|
|
132
|
+
vrt.stop()
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
### Assert
|
|
136
|
+
|
|
137
|
+
```python
|
|
138
|
+
result = vrt.track(TestRun(
|
|
139
|
+
# Name to be displayed
|
|
140
|
+
# Required
|
|
141
|
+
name='Image name',
|
|
142
|
+
|
|
143
|
+
# Base64 encoded string
|
|
144
|
+
# Required
|
|
145
|
+
imageBase64=image,
|
|
146
|
+
|
|
147
|
+
# Allowed mismatch tollerance in %
|
|
148
|
+
# Optional
|
|
149
|
+
# Default: 0%
|
|
150
|
+
diffTollerancePercent=1,
|
|
151
|
+
|
|
152
|
+
# Optional
|
|
153
|
+
os='Mac',
|
|
154
|
+
|
|
155
|
+
# Optional
|
|
156
|
+
browser='Chrome',
|
|
157
|
+
|
|
158
|
+
# Optional
|
|
159
|
+
viewport='800x600',
|
|
160
|
+
|
|
161
|
+
# Optional
|
|
162
|
+
device='PC',
|
|
163
|
+
|
|
164
|
+
# Array of areas to be ignored
|
|
165
|
+
ignoreAreas=[
|
|
166
|
+
IgnoreArea(
|
|
167
|
+
# X-coordinate relative of left upper corner
|
|
168
|
+
# Required
|
|
169
|
+
x=10,
|
|
170
|
+
# Y-coordinate relative of left upper corner
|
|
171
|
+
# Required
|
|
172
|
+
y=20,
|
|
173
|
+
# Area width in px
|
|
174
|
+
# Required
|
|
175
|
+
width=300,
|
|
176
|
+
# Height width in px
|
|
177
|
+
# Required
|
|
178
|
+
height=400
|
|
179
|
+
)
|
|
180
|
+
],
|
|
181
|
+
))
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
`track` returns a `TestRunResult`: `testRunResponse` (with `status` and the `url` of the test run in the
|
|
185
|
+
VRT app) and `imageUrl`, `diffUrl`, `baselineUrl`.
|
|
186
|
+
|
|
187
|
+
`track` raises `TestRunError` when the status is `new` (no baseline yet) or `unresolved` (difference found);
|
|
188
|
+
with `enableSoftAssert` it logs the error instead. `ok`, `approved` and `autoApproved` pass; `failed` passes
|
|
189
|
+
too, as in the JavaScript SDK. A status this SDK does not know becomes `TestRunStatus.UNKNOWN`.
|
|
190
|
+
|
|
191
|
+
An HTTP error from the server raises `ServerError` with `status_code` and the server's `message`.
|
|
192
|
+
A request that gets no answer (connection refused, connect timeout after 10 s, read timeout after
|
|
193
|
+
`httpTimeoutInSeconds`) raises `RequestError` with the `url`. A read timeout on `track` does not mean
|
|
194
|
+
the server dropped the test run: it may still be stored.
|
|
195
|
+
|
|
196
|
+
### Integration with Microsoft Playwright
|
|
197
|
+
|
|
198
|
+
#### Imports
|
|
199
|
+
```python
|
|
200
|
+
from playwright.sync_api import sync_playwright
|
|
201
|
+
from visual_regression_tracker import Config
|
|
202
|
+
from visual_regression_tracker.playwright import PlaywrightVisualRegressionTracker
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
#### Start playwright and navigate to page
|
|
206
|
+
```python
|
|
207
|
+
playwright = sync_playwright().start()
|
|
208
|
+
browserType = playwright.chromium
|
|
209
|
+
browser = browserType.launch(headless=False)
|
|
210
|
+
page = browser.new_page()
|
|
211
|
+
page.goto('https://www.python.org/')
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
#### Configure connection to VRT server
|
|
215
|
+
```python
|
|
216
|
+
vrt = PlaywrightVisualRegressionTracker(browserType, config)
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
#### Setup / Tear down
|
|
220
|
+
|
|
221
|
+
As context manager:
|
|
222
|
+
```python
|
|
223
|
+
with vrt:
|
|
224
|
+
...
|
|
225
|
+
# track test runs
|
|
226
|
+
...
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
Without context manager:
|
|
230
|
+
```python
|
|
231
|
+
vrt.start()
|
|
232
|
+
...
|
|
233
|
+
# track test runs
|
|
234
|
+
...
|
|
235
|
+
vrt.stop()
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
#### Track page
|
|
239
|
+
```python
|
|
240
|
+
result = vrt.trackPage(page, imageName[, options])
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
- `page: Page` [Playwright page](https://playwright.dev/python/docs/api/class-page)
|
|
244
|
+
|
|
245
|
+
- `imageName: str` name for the taken screenshot image
|
|
246
|
+
|
|
247
|
+
- `options: PageTrackOptions` optional configuration with:
|
|
248
|
+
- `diffTollerancePercent: float` specify acceptable difference from baseline, between `0-100`.
|
|
249
|
+
|
|
250
|
+
- `ignoreAreas: List[IgnoreArea]`
|
|
251
|
+
- `x: int` X-coordinate relative of left upper corner
|
|
252
|
+
- `y: int` Y-coordinate relative of left upper corner
|
|
253
|
+
- `width: int` area width in px
|
|
254
|
+
- `height: int` area height in px
|
|
255
|
+
|
|
256
|
+
- `screenshotOptions: PageScreenshotOptions` configuration for Playwrights `screenshot` method
|
|
257
|
+
- `full_page: bool` When true, takes a screenshot of the full scrollable page, instead of the currently visible viewport. Defaults to `false`.
|
|
258
|
+
|
|
259
|
+
- `omit_background: bool` Hides default white background and allows capturing screenshots with transparency. Defaults to `false`.
|
|
260
|
+
|
|
261
|
+
- `clip: FloatRect` An object which specifies clipping of the resulting image. Should have the following fields:
|
|
262
|
+
|
|
263
|
+
- `x: float` x-coordinate of top-left corner of clip area
|
|
264
|
+
- `y: float` y-coordinate of top-left corner of clip area
|
|
265
|
+
- `width: float` width of clipping area
|
|
266
|
+
- `height: float` height of clipping area
|
|
267
|
+
|
|
268
|
+
- `timeout: float` Maximum time in milliseconds, defaults to 30 seconds, pass 0 to disable timeout.
|
|
269
|
+
|
|
270
|
+
- `agent: Agent` Additional information to mark baseline across agents that have different:
|
|
271
|
+
- `os: str` operating system name, like Windows, Mac, etc.
|
|
272
|
+
- `device: str` device name, PC identifier, mobile identifier etc.
|
|
273
|
+
- `viewport: str` viewport size.
|
|
274
|
+
|
|
275
|
+
#### Track element handle
|
|
276
|
+
```python
|
|
277
|
+
result = vrt.trackElementHandle(elementHandle, imageName[, options])
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
The async API has `trackPageAsync` and `trackElementHandleAsync`. All four return the same `TestRunResult` as `track`.
|
|
281
|
+
|
|
282
|
+
- `elementHandle: ElementHandle` [Playwright ElementHandle](https://playwright.dev/python/docs/api/class-elementhandle)
|
|
283
|
+
|
|
284
|
+
- `imageName: str` name for the taken screenshot image
|
|
285
|
+
|
|
286
|
+
- `options: ElementHandleTrackOptions` optional configuration with:
|
|
287
|
+
- `diffTollerancePercent: float` specify acceptable difference from baseline, between `0-100`.
|
|
288
|
+
|
|
289
|
+
- `ignoreAreas: List[IgnoreArea]`
|
|
290
|
+
- `x: int` X-coordinate relative of left upper corner
|
|
291
|
+
- `y: int` Y-coordinate relative of left upper corner
|
|
292
|
+
- `width: int` area width in px
|
|
293
|
+
- `height: int` area height in px
|
|
294
|
+
|
|
295
|
+
- `screenshotOptions: ElementHandleScreenshotOptions` configuration for Playwrights `screenshot` method
|
|
296
|
+
|
|
297
|
+
- `omit_background: bool` Hides default white background and allows capturing screenshots with transparency. Defaults to `false`.
|
|
298
|
+
|
|
299
|
+
- `timeout: float` Maximum time in milliseconds, defaults to 30 seconds, pass 0 to disable timeout.
|
|
300
|
+
|
|
301
|
+
- `agent: Agent` Additional information to mark baseline across agents that have different:
|
|
302
|
+
- `os: str` operating system name, like Windows, Mac, etc.
|
|
303
|
+
- `device: str` device name, PC identifier, mobile identifier etc.
|
|
304
|
+
- `viewport: str` viewport size.
|
|
305
|
+
|
|
306
|
+
## Development
|
|
307
|
+
|
|
308
|
+
```sh
|
|
309
|
+
pip install -e '.[playwright]' -r requirements.txt
|
|
310
|
+
python -m playwright install chromium
|
|
311
|
+
python -m pytest
|
|
312
|
+
```
|
|
@@ -3,13 +3,15 @@
|
|
|
3
3
|
[](https://www.codacy.com/gh/Visual-Regression-Tracker/sdk-python?utm_source=github.com&utm_medium=referral&utm_content=Visual-Regression-Tracker/sdk-python&utm_campaign=Badge_Grade)
|
|
4
4
|
[](https://www.codacy.com/gh/Visual-Regression-Tracker/sdk-python?utm_source=github.com&utm_medium=referral&utm_content=Visual-Regression-Tracker/sdk-python&utm_campaign=Badge_Coverage)
|
|
5
5
|
|
|
6
|
+
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.
|
|
7
|
+
|
|
6
8
|
## Install
|
|
7
9
|
|
|
8
|
-
```
|
|
10
|
+
```sh
|
|
9
11
|
pip install visual-regression-tracker
|
|
10
12
|
|
|
11
13
|
# or, with playwright integration
|
|
12
|
-
pip install visual-regression-tracker[playwright]
|
|
14
|
+
pip install "visual-regression-tracker[playwright]"
|
|
13
15
|
python -m playwright install
|
|
14
16
|
```
|
|
15
17
|
|
|
@@ -18,7 +20,7 @@ python -m playwright install
|
|
|
18
20
|
### Import
|
|
19
21
|
|
|
20
22
|
```python
|
|
21
|
-
from visual_regression_tracker import VisualRegressionTracker, Config, TestRun
|
|
23
|
+
from visual_regression_tracker import VisualRegressionTracker, Config, TestRun, IgnoreArea
|
|
22
24
|
```
|
|
23
25
|
|
|
24
26
|
### Configure connection
|
|
@@ -43,6 +45,11 @@ config = Config(
|
|
|
43
45
|
|
|
44
46
|
# enableSoftAssert - Log errors instead of exceptions
|
|
45
47
|
enableSoftAssert=False,
|
|
48
|
+
|
|
49
|
+
# httpTimeoutInSeconds - How long to wait for the server's answer, 0 for no limit.
|
|
50
|
+
# The server compares images while answering track(); with VLM checks or a busy
|
|
51
|
+
# comparison queue that can take minutes, so keep it above 300.
|
|
52
|
+
httpTimeoutInSeconds=360,
|
|
46
53
|
)
|
|
47
54
|
|
|
48
55
|
vrt = VisualRegressionTracker(config)
|
|
@@ -56,9 +63,12 @@ vrt = VisualRegressionTracker(config)
|
|
|
56
63
|
"apiKey":"tXZVHX0EA4YQM1MGDD",
|
|
57
64
|
"ciBuildId":"commit_sha",
|
|
58
65
|
"branchName":"develop",
|
|
59
|
-
"enableSoftAssert":false
|
|
66
|
+
"enableSoftAssert":false,
|
|
67
|
+
"httpTimeoutInSeconds":360
|
|
60
68
|
}
|
|
61
69
|
```
|
|
70
|
+
|
|
71
|
+
`vrt.json` is read from the current working directory.
|
|
62
72
|
```python
|
|
63
73
|
vrt = VisualRegressionTracker()
|
|
64
74
|
```
|
|
@@ -71,8 +81,10 @@ VRT_APIKEY="tXZVHX0EA4YQM1MGDD" \
|
|
|
71
81
|
VRT_CIBUILDID="commit_sha" \
|
|
72
82
|
VRT_BRANCHNAME="develop" \
|
|
73
83
|
VRT_ENABLESOFTASSERT=true \
|
|
84
|
+
VRT_HTTPTIMEOUTINSECONDS=360 \
|
|
74
85
|
python
|
|
75
86
|
```
|
|
87
|
+
Empty variables are ignored.
|
|
76
88
|
```python
|
|
77
89
|
vrt = VisualRegressionTracker()
|
|
78
90
|
```
|
|
@@ -89,7 +101,7 @@ with vrt:
|
|
|
89
101
|
|
|
90
102
|
Without context manager:
|
|
91
103
|
```python
|
|
92
|
-
vrt.start()
|
|
104
|
+
build = vrt.start() # Build(id, projectId)
|
|
93
105
|
...
|
|
94
106
|
# track test runs
|
|
95
107
|
...
|
|
@@ -99,7 +111,7 @@ vrt.stop()
|
|
|
99
111
|
### Assert
|
|
100
112
|
|
|
101
113
|
```python
|
|
102
|
-
vrt.track(TestRun(
|
|
114
|
+
result = vrt.track(TestRun(
|
|
103
115
|
# Name to be displayed
|
|
104
116
|
# Required
|
|
105
117
|
name='Image name',
|
|
@@ -145,13 +157,25 @@ vrt.track(TestRun(
|
|
|
145
157
|
))
|
|
146
158
|
```
|
|
147
159
|
|
|
160
|
+
`track` returns a `TestRunResult`: `testRunResponse` (with `status` and the `url` of the test run in the
|
|
161
|
+
VRT app) and `imageUrl`, `diffUrl`, `baselineUrl`.
|
|
162
|
+
|
|
163
|
+
`track` raises `TestRunError` when the status is `new` (no baseline yet) or `unresolved` (difference found);
|
|
164
|
+
with `enableSoftAssert` it logs the error instead. `ok`, `approved` and `autoApproved` pass; `failed` passes
|
|
165
|
+
too, as in the JavaScript SDK. A status this SDK does not know becomes `TestRunStatus.UNKNOWN`.
|
|
166
|
+
|
|
167
|
+
An HTTP error from the server raises `ServerError` with `status_code` and the server's `message`.
|
|
168
|
+
A request that gets no answer (connection refused, connect timeout after 10 s, read timeout after
|
|
169
|
+
`httpTimeoutInSeconds`) raises `RequestError` with the `url`. A read timeout on `track` does not mean
|
|
170
|
+
the server dropped the test run: it may still be stored.
|
|
171
|
+
|
|
148
172
|
### Integration with Microsoft Playwright
|
|
149
173
|
|
|
150
174
|
#### Imports
|
|
151
175
|
```python
|
|
152
|
-
from playwright import sync_playwright
|
|
153
|
-
from visual_regression_tracker import Config
|
|
154
|
-
from visual_regression_tracker.
|
|
176
|
+
from playwright.sync_api import sync_playwright
|
|
177
|
+
from visual_regression_tracker import Config
|
|
178
|
+
from visual_regression_tracker.playwright import PlaywrightVisualRegressionTracker
|
|
155
179
|
```
|
|
156
180
|
|
|
157
181
|
#### Start playwright and navigate to page
|
|
@@ -159,7 +183,7 @@ from visual_regression_tracker.p import PlaywrightVisualRegressionTracker
|
|
|
159
183
|
playwright = sync_playwright().start()
|
|
160
184
|
browserType = playwright.chromium
|
|
161
185
|
browser = browserType.launch(headless=False)
|
|
162
|
-
page = browser.
|
|
186
|
+
page = browser.new_page()
|
|
163
187
|
page.goto('https://www.python.org/')
|
|
164
188
|
```
|
|
165
189
|
|
|
@@ -189,10 +213,10 @@ vrt.stop()
|
|
|
189
213
|
|
|
190
214
|
#### Track page
|
|
191
215
|
```python
|
|
192
|
-
vrt.trackPage(page, imageName[, options])
|
|
216
|
+
result = vrt.trackPage(page, imageName[, options])
|
|
193
217
|
```
|
|
194
218
|
|
|
195
|
-
- `page: Page` [Playwright page](https://
|
|
219
|
+
- `page: Page` [Playwright page](https://playwright.dev/python/docs/api/class-page)
|
|
196
220
|
|
|
197
221
|
- `imageName: str` name for the taken screenshot image
|
|
198
222
|
|
|
@@ -206,7 +230,7 @@ vrt.trackPage(page, imageName[, options])
|
|
|
206
230
|
- `height: int` area height in px
|
|
207
231
|
|
|
208
232
|
- `screenshotOptions: PageScreenshotOptions` configuration for Playwrights `screenshot` method
|
|
209
|
-
- `full_page: bool` When true, takes a screenshot of the full scrollable page, instead of the currently
|
|
233
|
+
- `full_page: bool` When true, takes a screenshot of the full scrollable page, instead of the currently visible viewport. Defaults to `false`.
|
|
210
234
|
|
|
211
235
|
- `omit_background: bool` Hides default white background and allows capturing screenshots with transparency. Defaults to `false`.
|
|
212
236
|
|
|
@@ -226,10 +250,12 @@ vrt.trackPage(page, imageName[, options])
|
|
|
226
250
|
|
|
227
251
|
#### Track element handle
|
|
228
252
|
```python
|
|
229
|
-
vrt.trackElementHandle(elementHandle, imageName[, options])
|
|
253
|
+
result = vrt.trackElementHandle(elementHandle, imageName[, options])
|
|
230
254
|
```
|
|
231
255
|
|
|
232
|
-
|
|
256
|
+
The async API has `trackPageAsync` and `trackElementHandleAsync`. All four return the same `TestRunResult` as `track`.
|
|
257
|
+
|
|
258
|
+
- `elementHandle: ElementHandle` [Playwright ElementHandle](https://playwright.dev/python/docs/api/class-elementhandle)
|
|
233
259
|
|
|
234
260
|
- `imageName: str` name for the taken screenshot image
|
|
235
261
|
|
|
@@ -252,3 +278,11 @@ vrt.trackElementHandle(elementHandle, imageName[, options])
|
|
|
252
278
|
- `os: str` operating system name, like Windows, Mac, etc.
|
|
253
279
|
- `device: str` device name, PC identifier, mobile identifier etc.
|
|
254
280
|
- `viewport: str` viewport size.
|
|
281
|
+
|
|
282
|
+
## Development
|
|
283
|
+
|
|
284
|
+
```sh
|
|
285
|
+
pip install -e '.[playwright]' -r requirements.txt
|
|
286
|
+
python -m playwright install chromium
|
|
287
|
+
python -m pytest
|
|
288
|
+
```
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=77"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "visual_regression_tracker"
|
|
7
|
+
version = "5.0.0"
|
|
8
|
+
description = "Open source, self hosted solution for visual testing and managing results of visual testing."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = "Apache-2.0"
|
|
11
|
+
license-files = ["LICENSE"]
|
|
12
|
+
requires-python = ">=3.10"
|
|
13
|
+
dependencies = [
|
|
14
|
+
"requests>=2.32.4",
|
|
15
|
+
"dacite>=1.9",
|
|
16
|
+
]
|
|
17
|
+
classifiers = [
|
|
18
|
+
"Programming Language :: Python :: 3",
|
|
19
|
+
"Programming Language :: Python :: 3.10",
|
|
20
|
+
"Programming Language :: Python :: 3.11",
|
|
21
|
+
"Programming Language :: Python :: 3.12",
|
|
22
|
+
"Programming Language :: Python :: 3.13",
|
|
23
|
+
"Programming Language :: Python :: 3.14",
|
|
24
|
+
"Topic :: Software Development :: Testing",
|
|
25
|
+
]
|
|
26
|
+
|
|
27
|
+
[project.optional-dependencies]
|
|
28
|
+
playwright = ["playwright>=1.50"]
|
|
29
|
+
|
|
30
|
+
[project.urls]
|
|
31
|
+
Homepage = "https://github.com/Visual-Regression-Tracker/Visual-Regression-Tracker"
|
|
32
|
+
Source = "https://github.com/Visual-Regression-Tracker/sdk-python"
|
|
33
|
+
Issues = "https://github.com/Visual-Regression-Tracker/sdk-python/issues"
|
|
34
|
+
|
|
35
|
+
[tool.setuptools]
|
|
36
|
+
packages = ["visual_regression_tracker"]
|
|
37
|
+
|
|
38
|
+
[tool.pytest.ini_options]
|
|
39
|
+
python_classes = "NoThanks"
|
|
40
|
+
junit_family = "xunit2"
|
|
41
|
+
asyncio_default_fixture_loop_scope = "function"
|