@applitools/driver 1.20.3 → 1.20.4
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.
- package/CHANGELOG.md +7 -0
- package/dist/driver.js +38 -23
- package/dist/fake/mock-driver.js +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [1.20.4](https://github.com/Applitools-Dev/sdk/compare/js/driver@1.20.3...js/driver@1.20.4) (2025-01-30)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Bug Fixes
|
|
7
|
+
|
|
8
|
+
* handle device screen info extraction gracefully ([#2757](https://github.com/Applitools-Dev/sdk/issues/2757)) ([92d0118](https://github.com/Applitools-Dev/sdk/commit/92d0118137b77e49d780092d110973df8ed8b40c))
|
|
9
|
+
|
|
3
10
|
## [1.20.3](https://github.com/Applitools-Dev/sdk/compare/js/driver@1.20.2...js/driver@1.20.3) (2025-01-13)
|
|
4
11
|
|
|
5
12
|
|
package/dist/driver.js
CHANGED
|
@@ -306,8 +306,8 @@ class Driver {
|
|
|
306
306
|
return this._environment;
|
|
307
307
|
}
|
|
308
308
|
async getViewport({ keepNavigationBar } = {}) {
|
|
309
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0;
|
|
310
|
-
var
|
|
309
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2;
|
|
310
|
+
var _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18;
|
|
311
311
|
if (!this._viewport) {
|
|
312
312
|
const environment = await this.getEnvironment();
|
|
313
313
|
const driverInfo = await this.getDriverInfo();
|
|
@@ -326,13 +326,13 @@ class Driver {
|
|
|
326
326
|
this._viewport = { ...capabilitiesViewport, ...this._viewport };
|
|
327
327
|
// this value always excludes the height of the navigation bar, and sometimes it also excludes the height of the status bar
|
|
328
328
|
let windowSize = await this._spec.getWindowSize(this.target);
|
|
329
|
-
(_a = (
|
|
329
|
+
(_a = (_3 = this._viewport).displaySize) !== null && _a !== void 0 ? _a : (_3.displaySize = windowSize);
|
|
330
330
|
if (((_b = this._viewport.orientation) === null || _b === void 0 ? void 0 : _b.startsWith('landscape')) &&
|
|
331
331
|
this._viewport.displaySize.height > this._viewport.displaySize.width) {
|
|
332
332
|
this._viewport.displaySize = utils.geometry.rotate(this._viewport.displaySize, 90);
|
|
333
333
|
}
|
|
334
334
|
if (environment.isAndroid) {
|
|
335
|
-
(_c = (
|
|
335
|
+
(_c = (_4 = this._viewport).pixelRatio) !== null && _c !== void 0 ? _c : (_4.pixelRatio = 1);
|
|
336
336
|
const { statusBar, navigationBar } = (_f = (await ((_e = (_d = this._spec).getSystemBars) === null || _e === void 0 ? void 0 : _e.call(_d, this.target).catch(() => undefined)))) !== null && _f !== void 0 ? _f : {};
|
|
337
337
|
if (statusBar === null || statusBar === void 0 ? void 0 : statusBar.visible) {
|
|
338
338
|
this._logger.log('Driver status bar', statusBar);
|
|
@@ -359,26 +359,41 @@ class Driver {
|
|
|
359
359
|
}
|
|
360
360
|
}
|
|
361
361
|
// bar sizes have to be scaled on android
|
|
362
|
-
(
|
|
363
|
-
(
|
|
362
|
+
(_5 = this._viewport).statusBarSize && (_5.statusBarSize = this._viewport.statusBarSize / this._viewport.pixelRatio);
|
|
363
|
+
(_6 = this._viewport).navigationBarSize && (_6.navigationBarSize = this._viewport.navigationBarSize / this._viewport.pixelRatio);
|
|
364
364
|
windowSize = utils.geometry.scale(windowSize, 1 / this._viewport.pixelRatio);
|
|
365
|
-
(
|
|
366
|
-
(_l = (
|
|
365
|
+
(_7 = this._viewport).displaySize && (_7.displaySize = utils.geometry.scale(this._viewport.displaySize, 1 / this._viewport.pixelRatio));
|
|
366
|
+
(_l = (_8 = this._viewport).navigationBarSize) !== null && _l !== void 0 ? _l : (_8.navigationBarSize = 0);
|
|
367
367
|
}
|
|
368
368
|
else if (environment.isIOS) {
|
|
369
369
|
if (!this._viewport.pixelRatio || !this._viewport.statusBarSize) {
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
370
|
+
try {
|
|
371
|
+
const screen = await this.execute('mobile:deviceScreenInfo');
|
|
372
|
+
this._viewport.pixelRatio = (_o = (_m = screen.scale) !== null && _m !== void 0 ? _m : this._viewport.pixelRatio) !== null && _o !== void 0 ? _o : 3;
|
|
373
|
+
this._viewport.statusBarSize = (_p = screen.statusBarSize) === null || _p === void 0 ? void 0 : _p.height;
|
|
374
|
+
}
|
|
375
|
+
catch (e) {
|
|
376
|
+
this._logger.log(`Unable to extract device screen info - fallback to heuristic`, e);
|
|
377
|
+
const scale2indicators = ['ipad', 'se', 'xr', 'iphone 11'];
|
|
378
|
+
if (scale2indicators.some(indicator => { var _a, _b; return (_b = (_a = this._environment) === null || _a === void 0 ? void 0 : _a.deviceName) === null || _b === void 0 ? void 0 : _b.toLowerCase().includes(indicator); })) {
|
|
379
|
+
this._viewport.pixelRatio = 2;
|
|
380
|
+
}
|
|
381
|
+
else {
|
|
382
|
+
this._viewport.pixelRatio = 3;
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
finally {
|
|
386
|
+
(_q = (_9 = this._viewport).statusBarSize) !== null && _q !== void 0 ? _q : (_9.statusBarSize = 0);
|
|
387
|
+
}
|
|
373
388
|
}
|
|
374
|
-
if ((
|
|
389
|
+
if ((_r = this._viewport.orientation) === null || _r === void 0 ? void 0 : _r.startsWith('landscape'))
|
|
375
390
|
this._viewport.statusBarSize = 0;
|
|
376
391
|
}
|
|
377
|
-
(
|
|
378
|
-
(
|
|
392
|
+
(_s = (_10 = this._viewport).pixelRatio) !== null && _s !== void 0 ? _s : (_10.pixelRatio = 1);
|
|
393
|
+
(_t = (_11 = this._viewport).statusBarSize) !== null && _t !== void 0 ? _t : (_11.statusBarSize = 0);
|
|
379
394
|
// calculate viewport location
|
|
380
|
-
(
|
|
381
|
-
x: this._viewport.orientation === 'landscape' ? (
|
|
395
|
+
(_u = (_12 = this._viewport).viewportLocation) !== null && _u !== void 0 ? _u : (_12.viewportLocation = {
|
|
396
|
+
x: this._viewport.orientation === 'landscape' ? (_v = this._viewport.navigationBarSize) !== null && _v !== void 0 ? _v : 0 : 0,
|
|
382
397
|
y: this._viewport.statusBarSize,
|
|
383
398
|
});
|
|
384
399
|
// calculate viewport size
|
|
@@ -386,7 +401,7 @@ class Driver {
|
|
|
386
401
|
this._viewport.viewportSize = { ...this._viewport.displaySize };
|
|
387
402
|
this._viewport.viewportSize.height -= this._viewport.statusBarSize;
|
|
388
403
|
if (environment.isAndroid && !keepNavigationBar) {
|
|
389
|
-
this._viewport.viewportSize[((
|
|
404
|
+
this._viewport.viewportSize[((_w = this._viewport.orientation) === null || _w === void 0 ? void 0 : _w.startsWith('landscape')) ? 'width' : 'height'] -=
|
|
390
405
|
this._viewport.navigationBarSize;
|
|
391
406
|
}
|
|
392
407
|
}
|
|
@@ -416,13 +431,13 @@ class Driver {
|
|
|
416
431
|
}
|
|
417
432
|
if (environment.isWeb) {
|
|
418
433
|
const browserViewport = await this.execute(snippets.getViewport);
|
|
419
|
-
(
|
|
420
|
-
(
|
|
421
|
-
(
|
|
422
|
-
(
|
|
434
|
+
(_x = (_13 = this._viewport).viewportSize) !== null && _x !== void 0 ? _x : (_13.viewportSize = browserViewport.viewportSize);
|
|
435
|
+
(_y = (_14 = this._viewport).pixelRatio) !== null && _y !== void 0 ? _y : (_14.pixelRatio = browserViewport.pixelRatio);
|
|
436
|
+
(_z = (_15 = this._viewport).viewportScale) !== null && _z !== void 0 ? _z : (_15.viewportScale = browserViewport.viewportScale);
|
|
437
|
+
(_0 = (_16 = this._viewport).orientation) !== null && _0 !== void 0 ? _0 : (_16.orientation = browserViewport.orientation);
|
|
423
438
|
}
|
|
424
|
-
(
|
|
425
|
-
(
|
|
439
|
+
(_1 = (_17 = this._viewport).pixelRatio) !== null && _1 !== void 0 ? _1 : (_17.pixelRatio = 1);
|
|
440
|
+
(_2 = (_18 = this._viewport).viewportScale) !== null && _2 !== void 0 ? _2 : (_18.viewportScale = 1);
|
|
426
441
|
this._logger.log('Extracted viewport', this._viewport);
|
|
427
442
|
}
|
|
428
443
|
return this._viewport;
|
package/dist/fake/mock-driver.js
CHANGED
|
@@ -130,7 +130,7 @@ class MockDriver {
|
|
|
130
130
|
});
|
|
131
131
|
});
|
|
132
132
|
this.mockScript(snippets.getViewport, () => {
|
|
133
|
-
return { viewportSize: { width: this._window.rect.width, height: this._window.rect.height },
|
|
133
|
+
return { viewportSize: { width: this._window.rect.width, height: this._window.rect.height }, pixelRatio: 1 };
|
|
134
134
|
});
|
|
135
135
|
this.mockScript(snippets.getElementXpath, ([element]) => {
|
|
136
136
|
if (element.xpath)
|