@applitools/driver 1.20.2 → 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 CHANGED
@@ -1,5 +1,22 @@
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
+
10
+ ## [1.20.3](https://github.com/Applitools-Dev/sdk/compare/js/driver@1.20.2...js/driver@1.20.3) (2025-01-13)
11
+
12
+
13
+ ### Dependencies
14
+
15
+ * @applitools/snippets bumped to 2.6.4
16
+ #### Bug Fixes
17
+
18
+ * remove side-eyes and fix code scanning issues ([#2712](https://github.com/Applitools-Dev/sdk/issues/2712)) ([cda98e4](https://github.com/Applitools-Dev/sdk/commit/cda98e4748c73cd97c11f646a2b5e26ff9416892))
19
+
3
20
  ## [1.20.2](https://github.com/Applitools-Dev/sdk/compare/js/driver@1.20.1...js/driver@1.20.2) (2024-12-31)
4
21
 
5
22
 
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 _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15;
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 = (_1 = this._viewport).displaySize) !== null && _a !== void 0 ? _a : (_1.displaySize = windowSize);
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 = (_2 = this._viewport).pixelRatio) !== null && _c !== void 0 ? _c : (_2.pixelRatio = 1);
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
- (_3 = this._viewport).statusBarSize && (_3.statusBarSize = this._viewport.statusBarSize / this._viewport.pixelRatio);
363
- (_4 = this._viewport).navigationBarSize && (_4.navigationBarSize = this._viewport.navigationBarSize / this._viewport.pixelRatio);
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
- (_5 = this._viewport).displaySize && (_5.displaySize = utils.geometry.scale(this._viewport.displaySize, 1 / this._viewport.pixelRatio));
366
- (_l = (_6 = this._viewport).navigationBarSize) !== null && _l !== void 0 ? _l : (_6.navigationBarSize = 0);
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
- const screen = await this.execute('mobile:deviceScreenInfo');
371
- this._viewport.pixelRatio = (_m = screen.scale) !== null && _m !== void 0 ? _m : 0;
372
- this._viewport.statusBarSize = (_o = screen.statusBarSize) === null || _o === void 0 ? void 0 : _o.height;
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 ((_p = this._viewport.orientation) === null || _p === void 0 ? void 0 : _p.startsWith('landscape'))
389
+ if ((_r = this._viewport.orientation) === null || _r === void 0 ? void 0 : _r.startsWith('landscape'))
375
390
  this._viewport.statusBarSize = 0;
376
391
  }
377
- (_q = (_7 = this._viewport).pixelRatio) !== null && _q !== void 0 ? _q : (_7.pixelRatio = 1);
378
- (_r = (_8 = this._viewport).statusBarSize) !== null && _r !== void 0 ? _r : (_8.statusBarSize = 0);
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
- (_s = (_9 = this._viewport).viewportLocation) !== null && _s !== void 0 ? _s : (_9.viewportLocation = {
381
- x: this._viewport.orientation === 'landscape' ? (_t = this._viewport.navigationBarSize) !== null && _t !== void 0 ? _t : 0 : 0,
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[((_u = this._viewport.orientation) === null || _u === void 0 ? void 0 : _u.startsWith('landscape')) ? 'width' : 'height'] -=
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
- (_v = (_10 = this._viewport).viewportSize) !== null && _v !== void 0 ? _v : (_10.viewportSize = browserViewport.viewportSize);
420
- (_w = (_11 = this._viewport).pixelRatio) !== null && _w !== void 0 ? _w : (_11.pixelRatio = browserViewport.pixelRatio);
421
- (_x = (_12 = this._viewport).viewportScale) !== null && _x !== void 0 ? _x : (_12.viewportScale = browserViewport.viewportScale);
422
- (_y = (_13 = this._viewport).orientation) !== null && _y !== void 0 ? _y : (_13.orientation = browserViewport.orientation);
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
- (_z = (_14 = this._viewport).pixelRatio) !== null && _z !== void 0 ? _z : (_14.pixelRatio = 1);
425
- (_0 = (_15 = this._viewport).viewportScale) !== null && _0 !== void 0 ? _0 : (_15.viewportScale = 1);
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;
@@ -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 }, pixelRation: 1 };
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)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@applitools/driver",
3
- "version": "1.20.2",
3
+ "version": "1.20.4",
4
4
  "description": "Applitools universal framework wrapper",
5
5
  "keywords": [
6
6
  "applitools",
@@ -74,7 +74,7 @@
74
74
  },
75
75
  "dependencies": {
76
76
  "@applitools/logger": "2.1.0",
77
- "@applitools/snippets": "2.6.3",
77
+ "@applitools/snippets": "2.6.4",
78
78
  "@applitools/utils": "1.7.7",
79
79
  "semver": "7.6.2"
80
80
  },