@applitools/driver 1.9.4 → 1.9.5

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.
@@ -33,9 +33,13 @@ function parseCapabilities(capabilities, customConfig) {
33
33
  info.orientation = (_m = ((_l = capabilities.deviceOrientation) !== null && _l !== void 0 ? _l : capabilities.orientation)) === null || _m === void 0 ? void 0 : _m.toLowerCase();
34
34
  }
35
35
  if (info.isNative) {
36
+ info.displaySize = extractDisplaySize(capabilities);
36
37
  info.pixelRatio = capabilities.pixelRatio;
37
38
  info.statusBarHeight = capabilities.statBarHeight;
38
- info.displaySize = extractDisplaySize(capabilities);
39
+ if (info.displaySize && capabilities.viewportRect) {
40
+ info.navigationBarHeight =
41
+ info.displaySize.height - (capabilities.viewportRect.top + capabilities.viewportRect.height);
42
+ }
39
43
  }
40
44
  return info;
41
45
  }
package/dist/driver.js CHANGED
@@ -184,11 +184,11 @@ class Driver {
184
184
  // navigation bar height is replaced with the width in landscape orientation on android (due to the bug in appium)
185
185
  if (orientation === 'landscape')
186
186
  barsSize.navigationBarHeight = barsSize.navigationBarWidth;
187
- // when status bar is overlapping content on android it returns status bar height equal to viewport height
187
+ // when status bar is overlapping content on android it returns status bar height equal to display height
188
188
  if (barsSize.statusBarHeight < this._driverInfo.displaySize.height) {
189
189
  this._driverInfo.statusBarHeight = Math.max((_u = this._driverInfo.statusBarHeight) !== null && _u !== void 0 ? _u : 0, barsSize.statusBarHeight);
190
190
  }
191
- // when navigation bar is invisible on android it returns navigation bar height equal to viewport height
191
+ // when navigation bar is invisible on android it returns navigation bar height equal to display height
192
192
  if (barsSize.navigationBarHeight < this._driverInfo.displaySize.height) {
193
193
  this._driverInfo.navigationBarHeight = Math.max((_v = this._driverInfo.navigationBarHeight) !== null && _v !== void 0 ? _v : 0, barsSize.navigationBarHeight);
194
194
  }
package/dist/element.js CHANGED
@@ -288,7 +288,7 @@ class Element {
288
288
  if (((_a = this.driver.helper) === null || _a === void 0 ? void 0 : _a.name) === 'android') {
289
289
  this._state.touchPadding = await ((_b = this.driver.helper) === null || _b === void 0 ? void 0 : _b.getTouchPadding());
290
290
  }
291
- else {
291
+ if (!this._state.touchPadding) {
292
292
  const touchPadding = await this.getAttribute('contentSize')
293
293
  .then(data => JSON.parse(data).touchPadding)
294
294
  .catch(err => {
@@ -394,15 +394,16 @@ class Element {
394
394
  remainingOffset = utils.geometry.round(utils.geometry.scale(remainingOffset, this.driver.pixelRatio));
395
395
  effectiveRegion = utils.geometry.round(utils.geometry.scale(effectiveRegion, this.driver.pixelRatio));
396
396
  }
397
- const actions = [];
398
397
  const isPager = await this.isPager();
399
398
  const touchPadding = await this.getTouchPadding();
399
+ const actions = [];
400
400
  // horizontal scrolling
401
- const xPadding = Math.max(Math.floor(effectiveRegion.width * 0.07), touchPadding);
401
+ const xPadding = touchPadding + 3;
402
402
  const yTrack = Math.floor(effectiveRegion.y + effectiveRegion.height / 2); // center
403
403
  const xLeft = effectiveRegion.y + xPadding;
404
404
  const xDirection = remainingOffset.x > 0 ? 'right' : 'left';
405
405
  const xGap = xDirection === 'right' ? -touchPadding : touchPadding;
406
+ const xCompensation = xDirection === 'right' ? -1 : 1;
406
407
  let xRemaining = Math.abs(remainingOffset.x);
407
408
  if (isPager) {
408
409
  const xPages = Math.floor(xRemaining / effectiveRegion.width);
@@ -420,29 +421,44 @@ class Element {
420
421
  { action: 'release' },
421
422
  ]);
422
423
  }
423
- else {
424
+ else if (this.driver.isAndroid) {
425
+ actions.push([
426
+ // move through scrolling gap (actual scrolling will be triggered only after that)
427
+ { action: 'press', y: yTrack, x: xStart - xGap },
428
+ { action: 'wait', ms: 100 },
429
+ { action: 'moveTo', y: yTrack, x: xStart + xCompensation },
430
+ { action: 'wait', ms: 100 },
431
+ { action: 'moveTo', y: yTrack, x: xStart },
432
+ // perform actual scrolling
433
+ { action: 'wait', ms: 100 },
434
+ { action: 'moveTo', y: yTrack, x: xEnd },
435
+ { action: 'release' },
436
+ ]);
437
+ }
438
+ else if (this.driver.isIOS) {
424
439
  actions.push([
425
- { action: 'press', y: yTrack, x: xStart },
426
440
  // move through scrolling gap (actual scrolling will be triggered only after that)
441
+ { action: 'press', y: yTrack, x: xStart - xGap },
427
442
  { action: 'wait', ms: 100 },
428
- { action: 'moveTo', y: yTrack, x: xStart + xGap },
443
+ { action: 'moveTo', y: yTrack, x: xStart },
429
444
  // perform actual scrolling
430
445
  { action: 'wait', ms: 100 },
431
- { action: 'moveTo', y: yTrack, x: xEnd + xGap },
446
+ { action: 'moveTo', y: yTrack, x: xEnd },
432
447
  // prevent inertial scrolling after release
433
448
  { action: 'wait', ms: 100 },
434
- { action: 'moveTo', y: yTrack + 1, x: xEnd + xGap },
449
+ { action: 'moveTo', y: yTrack + 1, x: xEnd },
435
450
  { action: 'release' },
436
451
  ]);
437
452
  }
438
453
  xRemaining -= xRight - xLeft;
439
454
  }
440
455
  // vertical scrolling
441
- const yPadding = Math.max(Math.floor(effectiveRegion.height * 0.07), touchPadding);
456
+ const yPadding = Math.max(Math.floor(effectiveRegion.height * 0.05), touchPadding + 3);
442
457
  const xTrack = Math.floor(effectiveRegion.x + 5); // a little bit off left border
443
458
  const yBottom = effectiveRegion.y + effectiveRegion.height - yPadding;
444
459
  const yDirection = remainingOffset.y > 0 ? 'down' : 'up';
445
460
  const yGap = yDirection === 'down' ? -touchPadding : touchPadding;
461
+ const yCompensation = yDirection === 'down' ? -1 : 1;
446
462
  let yRemaining = Math.abs(remainingOffset.y);
447
463
  if (isPager) {
448
464
  const yPages = Math.floor(yRemaining / effectiveRegion.height);
@@ -460,18 +476,32 @@ class Element {
460
476
  { action: 'release' },
461
477
  ]);
462
478
  }
463
- else {
479
+ else if (this.driver.isAndroid) {
464
480
  actions.push([
465
- { action: 'press', x: xTrack, y: yStart },
466
481
  // move through scrolling gap (actual scrolling will be triggered only after that)
482
+ { action: 'press', x: xTrack, y: yStart - yGap },
467
483
  { action: 'wait', ms: 100 },
468
- { action: 'moveTo', x: xTrack, y: yStart + yGap },
484
+ { action: 'moveTo', x: xTrack, y: yStart + yCompensation },
485
+ { action: 'wait', ms: 100 },
486
+ { action: 'moveTo', x: xTrack, y: yStart },
469
487
  // perform actual scrolling
470
488
  { action: 'wait', ms: 100 },
471
- { action: 'moveTo', x: xTrack, y: yEnd + yGap },
489
+ { action: 'moveTo', x: xTrack, y: yEnd },
490
+ { action: 'release' },
491
+ ]);
492
+ }
493
+ else if (this.driver.isIOS) {
494
+ actions.push([
495
+ // move through scrolling gap (actual scrolling will be triggered only after that)
496
+ { action: 'press', x: xTrack, y: yStart - yGap },
497
+ { action: 'wait', ms: 100 },
498
+ { action: 'moveTo', x: xTrack, y: yStart },
499
+ // perform actual scrolling
500
+ { action: 'wait', ms: 100 },
501
+ { action: 'moveTo', x: xTrack, y: yEnd },
472
502
  // prevent inertial scrolling after release
473
503
  { action: 'wait', ms: 100 },
474
- { action: 'moveTo', x: xTrack + 1, y: yEnd + yGap },
504
+ { action: 'moveTo', x: xTrack + 1, y: yEnd },
475
505
  { action: 'release' },
476
506
  ]);
477
507
  }
@@ -488,10 +518,10 @@ class Element {
488
518
  await this._spec.performAction(this.driver.target, [].concat(...actions));
489
519
  }
490
520
  const actualScrollableRegion = await this.getClientRegion();
491
- this._state.scrollOffset = utils.geometry.round(utils.geometry.offsetNegative(requiredOffset, {
521
+ this._state.scrollOffset = utils.geometry.offsetNegative(requiredOffset, {
492
522
  x: scrollableRegion.x - actualScrollableRegion.x,
493
523
  y: scrollableRegion.y - actualScrollableRegion.y,
494
- }));
524
+ });
495
525
  return this._state.scrollOffset;
496
526
  }
497
527
  });
@@ -1,6 +1,30 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
2
25
  Object.defineProperty(exports, "__esModule", { value: true });
3
26
  exports.HelperAndroid = void 0;
27
+ const utils = __importStar(require("@applitools/utils"));
4
28
  class HelperAndroid {
5
29
  constructor(options) {
6
30
  this._spec = options.spec;
@@ -32,10 +56,10 @@ class HelperAndroid {
32
56
  return resourceId.split('/')[1];
33
57
  }
34
58
  async getContentSize(element) {
35
- let contentHeight;
59
+ let contentHeightString;
36
60
  if (this._legacy) {
37
61
  await this._element.click();
38
- contentHeight = await this._element.getText();
62
+ contentHeightString = await this._element.getText();
39
63
  }
40
64
  else {
41
65
  const elementId = await this._getElementId(element);
@@ -43,11 +67,14 @@ class HelperAndroid {
43
67
  return null;
44
68
  await this._element.type(`offset;${elementId};0;0;0`);
45
69
  await this._element.click();
46
- contentHeight = await this._element.getText();
70
+ contentHeightString = await this._element.getText();
47
71
  await this._element.type('');
48
72
  }
49
73
  const region = await this._spec.getElementRegion(this._element.driver.target, element.target);
50
- return { width: region.width, height: Number(contentHeight) };
74
+ const contentHeight = Number(contentHeightString);
75
+ if (Number.isNaN(contentHeight))
76
+ return utils.geometry.size(region);
77
+ return { width: region.width, height: contentHeight };
51
78
  }
52
79
  async getRegion(element) {
53
80
  if (this._legacy)
@@ -71,7 +98,7 @@ class HelperAndroid {
71
98
  const elementId = await this._getElementId(element);
72
99
  if (!elementId)
73
100
  return null;
74
- await this._element.type(`moveToTop;${elementId};0;0`);
101
+ await this._element.type(`moveToTop;${elementId};0;-1`);
75
102
  await this._element.click();
76
103
  await this._element.type('');
77
104
  }
@@ -92,7 +119,10 @@ class HelperAndroid {
92
119
  await this._element.click();
93
120
  const touchPaddingString = await this._element.getText();
94
121
  await this._element.type('');
95
- return Number(touchPaddingString);
122
+ const touchPadding = Number(touchPaddingString);
123
+ if (Number.isNaN(touchPadding))
124
+ return null;
125
+ return touchPadding;
96
126
  }
97
127
  }
98
128
  exports.HelperAndroid = HelperAndroid;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@applitools/driver",
3
- "version": "1.9.4",
3
+ "version": "1.9.5",
4
4
  "description": "Applitools universal framework wrapper",
5
5
  "keywords": [
6
6
  "applitools",
@@ -76,10 +76,10 @@
76
76
  }
77
77
  },
78
78
  "dependencies": {
79
- "@applitools/logger": "1.1.12",
80
- "@applitools/snippets": "2.4.2",
81
- "@applitools/types": "1.5.3",
82
- "@applitools/utils": "1.3.8"
79
+ "@applitools/logger": "1.1.13",
80
+ "@applitools/snippets": "2.4.3",
81
+ "@applitools/types": "1.5.4",
82
+ "@applitools/utils": "1.3.9"
83
83
  },
84
84
  "devDependencies": {
85
85
  "@applitools/bongo": "^2.1.5",