@applitools/driver 1.3.1 → 1.3.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.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,22 @@
3
3
  ## Unreleased
4
4
 
5
5
 
6
+ ## 1.3.5 - 2021/11/23
7
+
8
+ - updated to @applitools/types@1.0.21 (from 1.0.20)
9
+
10
+ ## 1.3.4 - 2021/11/18
11
+
12
+ - fix capabilities parsing for native apps
13
+
14
+ ## 1.3.3 - 2021/11/14
15
+
16
+ - do not throw if `getCookies` method is missed in spec driver
17
+
18
+ ## 1.3.2 - 2021/11/14
19
+
20
+ - adjust scrolling algorithm on native devices
21
+
6
22
  ## 1.3.1 - 2021/11/14
7
23
 
8
24
  - add in-house capability parsing and system bars size handling mechanisms
@@ -4,7 +4,9 @@ exports.parseCapabilities = void 0;
4
4
  function parseCapabilities(capabilities) {
5
5
  var _a, _b, _c, _d, _e, _f, _g, _h;
6
6
  const info = {
7
- browserName: ((_a = capabilities.browserName) !== null && _a !== void 0 ? _a : (_b = capabilities.desired) === null || _b === void 0 ? void 0 : _b.browserName) || undefined,
7
+ browserName: !capabilities.app
8
+ ? ((_a = capabilities.browserName) !== null && _a !== void 0 ? _a : (_b = capabilities.desired) === null || _b === void 0 ? void 0 : _b.browserName) || undefined
9
+ : undefined,
8
10
  browserVersion: ((_c = capabilities.browserVersion) !== null && _c !== void 0 ? _c : capabilities.version) || undefined,
9
11
  platformName: ((_e = (_d = capabilities.platformName) !== null && _d !== void 0 ? _d : capabilities.platform) !== null && _e !== void 0 ? _e : (_f = capabilities.desired) === null || _f === void 0 ? void 0 : _f.platformName) || undefined,
10
12
  platformVersion: capabilities.platformVersion || undefined,
package/dist/context.js CHANGED
@@ -438,11 +438,11 @@ class Context {
438
438
  return region;
439
439
  }
440
440
  async getCookies() {
441
- var _a, _b;
441
+ var _a, _b, _c;
442
442
  if (this.driver.isNative)
443
443
  return [];
444
444
  await this.focus();
445
- return (_b = (_a = this._spec) === null || _a === void 0 ? void 0 : _a.getCookies(this.target, true)) !== null && _b !== void 0 ? _b : [];
445
+ return (_c = (_b = (_a = this._spec).getCookies) === null || _b === void 0 ? void 0 : _b.call(_a, this.target, true)) !== null && _c !== void 0 ? _c : [];
446
446
  }
447
447
  async preserveInnerOffset() {
448
448
  this._state.innerOffset = await this.getInnerOffset();
package/dist/driver.js CHANGED
@@ -156,8 +156,8 @@ class Driver {
156
156
  if (this.isNative) {
157
157
  const barsHeight = await ((_r = (_q = this._spec).getBarsHeight) === null || _r === void 0 ? void 0 : _r.call(_q, this.target).catch(() => undefined));
158
158
  if (barsHeight) {
159
- this._driverInfo.statusBarHeight = Math.max(barsHeight.statusBarHeight, driverInfo.statusBarHeight);
160
- this._driverInfo.navigationBarHeight = Math.max(barsHeight.navigationBarHeight, driverInfo.navigationBarHeight);
159
+ this._driverInfo.statusBarHeight = Math.max(this._driverInfo.statusBarHeight, barsHeight.statusBarHeight);
160
+ this._driverInfo.navigationBarHeight = Math.max(this._driverInfo.navigationBarHeight, barsHeight.navigationBarHeight);
161
161
  }
162
162
  if (this.isAndroid) {
163
163
  this._driverInfo.statusBarHeight /= this.pixelRatio;
@@ -434,10 +434,10 @@ class Driver {
434
434
  return orientation;
435
435
  }
436
436
  async getCookies() {
437
- var _a, _b;
437
+ var _a, _b, _c;
438
438
  if (this.isNative || !this.features.allCookies)
439
439
  return [];
440
- return (_b = (_a = this._spec) === null || _a === void 0 ? void 0 : _a.getCookies(this.target)) !== null && _b !== void 0 ? _b : [];
440
+ return (_c = (_b = (_a = this._spec).getCookies) === null || _b === void 0 ? void 0 : _b.call(_a, this.target)) !== null && _c !== void 0 ? _c : [];
441
441
  }
442
442
  async getTitle() {
443
443
  if (this.isNative)
package/dist/element.js CHANGED
@@ -328,25 +328,25 @@ class Element {
328
328
  }
329
329
  const actions = [];
330
330
  const xPadding = Math.floor(scrollableRegion.width * 0.1);
331
- const yCenter = Math.floor(scrollableRegion.y + scrollableRegion.height / 2);
331
+ const yTrack = Math.floor(scrollableRegion.y + scrollableRegion.height / 2); // center
332
332
  const xLeft = scrollableRegion.y + xPadding;
333
333
  const xDirection = remainingOffset.y > 0 ? 'right' : 'left';
334
334
  let xRemaining = Math.abs(remainingOffset.x);
335
335
  while (xRemaining > 0) {
336
336
  const xRight = scrollableRegion.x + Math.min(xRemaining + xPadding, scrollableRegion.width - xPadding);
337
337
  const [xStart, xEnd] = xDirection === 'right' ? [xRight, xLeft] : [xLeft, xRight];
338
- actions.push({ action: 'press', x: xStart, y: yCenter }, { action: 'wait', ms: 1500 }, { action: 'moveTo', x: xEnd, y: yCenter }, { action: 'release' });
338
+ actions.push({ action: 'press', x: xStart, y: yTrack }, { action: 'wait', ms: 1500 }, { action: 'moveTo', x: xEnd, y: yTrack }, { action: 'release' });
339
339
  xRemaining -= xRight - xLeft;
340
340
  }
341
- const yPadding = Math.floor(scrollableRegion.height * 0.08);
342
- const xCenter = Math.floor(scrollableRegion.x + scrollableRegion.width / 2); // 0
341
+ const yPadding = Math.floor(scrollableRegion.height * 0.1);
342
+ const xTrack = Math.floor(scrollableRegion.x + 5); // a little bit off left border
343
343
  const yTop = scrollableRegion.y + yPadding;
344
344
  const yDirection = remainingOffset.y > 0 ? 'down' : 'up';
345
345
  let yRemaining = Math.abs(remainingOffset.y) + (await this.getTouchPadding()) * 2;
346
346
  while (yRemaining > 0) {
347
347
  const yBottom = scrollableRegion.y + Math.min(yRemaining + yPadding, scrollableRegion.height - yPadding);
348
348
  const [yStart, yEnd] = yDirection === 'down' ? [yBottom, yTop] : [yTop, yBottom];
349
- actions.push({ action: 'press', x: xCenter, y: yStart }, { action: 'wait', ms: 1500 }, { action: 'moveTo', x: xCenter, y: yEnd }, { action: 'wait', ms: 1500 }, { action: 'release' });
349
+ actions.push({ action: 'press', x: xTrack, y: yStart }, { action: 'wait', ms: 1500 }, { action: 'moveTo', x: xTrack, y: yEnd }, { action: 'wait', ms: 1500 }, { action: 'release' });
350
350
  yRemaining -= yBottom - yTop;
351
351
  }
352
352
  if (actions.length > 0) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@applitools/driver",
3
- "version": "1.3.1",
3
+ "version": "1.3.5",
4
4
  "description": "Applitools universal framework wrapper",
5
5
  "keywords": [
6
6
  "applitools",
@@ -36,6 +36,13 @@
36
36
  "types": "./types/fake/index.d.ts"
37
37
  }
38
38
  },
39
+ "typesVersions": {
40
+ "*": {
41
+ "fake": [
42
+ "./types/fake/index.d.ts"
43
+ ]
44
+ }
45
+ },
39
46
  "files": [
40
47
  "dist",
41
48
  "types"
@@ -56,7 +63,7 @@
56
63
  },
57
64
  "dependencies": {
58
65
  "@applitools/snippets": "2.1.7",
59
- "@applitools/types": "1.0.20",
66
+ "@applitools/types": "1.0.21",
60
67
  "@applitools/utils": "1.2.4"
61
68
  },
62
69
  "devDependencies": {
@@ -20,7 +20,7 @@ export declare class MockDriver {
20
20
  browserVersion: any;
21
21
  };
22
22
  executeScript(script: any, args?: any[]): Promise<any>;
23
- findElement(selector: any, rootElement: any): Promise<any>;
23
+ findElement(selector: any, rootElement?: any): Promise<any>;
24
24
  findElements(selector: any, rootElement: any): Promise<any>;
25
25
  switchToFrame(reference: any): Promise<this>;
26
26
  switchToParentFrame(): Promise<this>;