@applitools/driver 1.7.2 → 1.8.2

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.
@@ -1,26 +1,36 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.parseCapabilities = void 0;
4
- function parseCapabilities(capabilities) {
5
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
4
+ function parseCapabilities(capabilities, customConfig) {
5
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
6
6
  if (capabilities.capabilities)
7
7
  capabilities = capabilities.capabilities;
8
+ if (!(customConfig === null || customConfig === void 0 ? void 0 : customConfig.keepPlatformNameAsIs)) {
9
+ // We use `startsWith` for just a theorerical reason. It's not based on any concrete case that we knew of at the time of writing this code.
10
+ if ((_a = capabilities.platformName) === null || _a === void 0 ? void 0 : _a.startsWith('android')) {
11
+ capabilities.platformName = capabilities.platformName.charAt(0).toUpperCase() + capabilities.platformName.slice(1);
12
+ }
13
+ // We use `startsWith` for just a theorerical reason. It's not based on any concrete case that we knew of at the time of writing this code.
14
+ if ((_b = capabilities.platformName) === null || _b === void 0 ? void 0 : _b.startsWith('ios')) {
15
+ capabilities.platformName = 'iOS' + capabilities.platformName.slice(3);
16
+ }
17
+ }
8
18
  const info = {
9
19
  browserName: !capabilities.app && !capabilities.bundleId
10
- ? ((_a = capabilities.browserName) !== null && _a !== void 0 ? _a : (_b = capabilities.desired) === null || _b === void 0 ? void 0 : _b.browserName) || undefined
20
+ ? ((_c = capabilities.browserName) !== null && _c !== void 0 ? _c : (_d = capabilities.desired) === null || _d === void 0 ? void 0 : _d.browserName) || undefined
11
21
  : undefined,
12
- browserVersion: ((_c = capabilities.browserVersion) !== null && _c !== void 0 ? _c : capabilities.version) || undefined,
13
- 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,
22
+ browserVersion: ((_e = capabilities.browserVersion) !== null && _e !== void 0 ? _e : capabilities.version) || undefined,
23
+ platformName: ((_g = (_f = capabilities.platformName) !== null && _f !== void 0 ? _f : capabilities.platform) !== null && _g !== void 0 ? _g : (_h = capabilities.desired) === null || _h === void 0 ? void 0 : _h.platformName) || undefined,
14
24
  platformVersion: capabilities.platformVersion || undefined,
15
25
  isW3C: isW3C(capabilities),
16
26
  isMobile: isMobile(capabilities),
17
27
  };
18
28
  if (info.isMobile) {
19
- info.deviceName = ((_h = (_g = capabilities.desired) === null || _g === void 0 ? void 0 : _g.deviceName) !== null && _h !== void 0 ? _h : capabilities.deviceName) || undefined;
29
+ info.deviceName = ((_k = (_j = capabilities.desired) === null || _j === void 0 ? void 0 : _j.deviceName) !== null && _k !== void 0 ? _k : capabilities.deviceName) || undefined;
20
30
  info.isNative = info.isMobile && !info.browserName;
21
31
  info.isIOS = isIOS(capabilities);
22
32
  info.isAndroid = isAndroid(capabilities);
23
- info.orientation = (_k = ((_j = capabilities.deviceOrientation) !== null && _j !== void 0 ? _j : capabilities.orientation)) === null || _k === void 0 ? void 0 : _k.toLowerCase();
33
+ info.orientation = (_m = ((_l = capabilities.deviceOrientation) !== null && _l !== void 0 ? _l : capabilities.orientation)) === null || _m === void 0 ? void 0 : _m.toLowerCase();
24
34
  }
25
35
  if (info.isNative) {
26
36
  info.pixelRatio = capabilities.pixelRatio;
package/dist/driver.js CHANGED
@@ -144,7 +144,7 @@ class Driver {
144
144
  var _w, _x, _y, _z, _0, _1, _2, _3;
145
145
  const capabilities = await ((_b = (_a = this._spec).getCapabilities) === null || _b === void 0 ? void 0 : _b.call(_a, this.target));
146
146
  this._logger.log('Driver capabilities', capabilities);
147
- const capabilitiesInfo = capabilities ? capabilities_1.parseCapabilities(capabilities) : undefined;
147
+ const capabilitiesInfo = capabilities ? capabilities_1.parseCapabilities(capabilities, this._customConfig) : undefined;
148
148
  const driverInfo = await ((_d = (_c = this._spec).getDriverInfo) === null || _d === void 0 ? void 0 : _d.call(_c, this.target));
149
149
  this._driverInfo = Object.assign(Object.assign({}, capabilitiesInfo), driverInfo);
150
150
  if (this.isWeb) {
@@ -381,11 +381,11 @@ class Driver {
381
381
  }
382
382
  return this.currentContext;
383
383
  }
384
- async normalizeRegion(region, shouldIgnoreSafeRegion) {
384
+ async normalizeRegion(region) {
385
385
  if (this.isWeb || !utils.types.has(this._driverInfo, ['viewportSize', 'statusBarHeight']))
386
386
  return region;
387
387
  const scaledRegion = this.isAndroid ? utils.geometry.scale(region, 1 / this.pixelRatio) : region;
388
- const safeRegion = this.isIOS && !shouldIgnoreSafeRegion
388
+ const safeRegion = this.isIOS && utils.geometry.isIntersected(scaledRegion, this._driverInfo.safeArea)
389
389
  ? utils.geometry.intersect(scaledRegion, this._driverInfo.safeArea)
390
390
  : scaledRegion;
391
391
  const offsetRegion = utils.geometry.offsetNegative(safeRegion, {
package/dist/element.js CHANGED
@@ -106,7 +106,7 @@ class Element {
106
106
  return this;
107
107
  }
108
108
  }
109
- async getRegion(shouldIgnoreSafeRegion) {
109
+ async getRegion() {
110
110
  const region = await this.withRefresh(async () => {
111
111
  if (this.driver.isWeb) {
112
112
  this._logger.log('Extracting region of web element with selector', this.selector);
@@ -116,7 +116,7 @@ class Element {
116
116
  this._logger.log('Extracting region of native element with selector', this.selector);
117
117
  const region = await this._spec.getElementRegion(this.driver.target, this.target);
118
118
  this._logger.log('Extracted native region', region);
119
- return this.driver.normalizeRegion(region, shouldIgnoreSafeRegion);
119
+ return this.driver.normalizeRegion(region);
120
120
  }
121
121
  });
122
122
  this._logger.log('Extracted region', region);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@applitools/driver",
3
- "version": "1.7.2",
3
+ "version": "1.8.2",
4
4
  "description": "Applitools universal framework wrapper",
5
5
  "keywords": [
6
6
  "applitools",
@@ -74,12 +74,12 @@
74
74
  },
75
75
  "dependencies": {
76
76
  "@applitools/snippets": "2.2.3",
77
- "@applitools/types": "1.3.2",
78
- "@applitools/utils": "1.2.14"
77
+ "@applitools/types": "1.4.2",
78
+ "@applitools/utils": "1.3.0"
79
79
  },
80
80
  "devDependencies": {
81
81
  "@applitools/bongo": "^2.0.3",
82
- "@types/mocha": "^9.0.0",
82
+ "@types/mocha": "^9.1.1",
83
83
  "@types/node": "^16.3.3",
84
84
  "@typescript-eslint/eslint-plugin": "^4.28.3",
85
85
  "@typescript-eslint/parser": "^4.28.3",
@@ -1,4 +1,4 @@
1
1
  import type * as types from '@applitools/types';
2
2
  declare type Capabilities = Record<string, any>;
3
- export declare function parseCapabilities(capabilities: Capabilities): types.DriverInfo;
3
+ export declare function parseCapabilities(capabilities: Capabilities, customConfig?: types.CustomCapabilitiesConfig): types.DriverInfo;
4
4
  export {};
package/types/driver.d.ts CHANGED
@@ -17,7 +17,7 @@ export declare class Driver<TDriver, TContext, TElement, TSelector> {
17
17
  spec: types.SpecDriver<TDriver, TContext, TElement, TSelector>;
18
18
  driver: Driver<TDriver, TContext, TElement, TSelector> | TDriver;
19
19
  logger?: any;
20
- customConfig?: any;
20
+ customConfig?: types.CustomDriverConfig;
21
21
  });
22
22
  get target(): TDriver;
23
23
  get currentContext(): Context<TDriver, TContext, TElement, TSelector>;
@@ -52,7 +52,7 @@ export declare class Driver<TDriver, TContext, TElement, TSelector> {
52
52
  switchToMainContext(): Promise<Context<TDriver, TContext, TElement, TSelector>>;
53
53
  switchToParentContext(elevation?: number): Promise<Context<TDriver, TContext, TElement, TSelector>>;
54
54
  switchToChildContext(...references: ContextReference<TDriver, TContext, TElement, TSelector>[]): Promise<Context<TDriver, TContext, TElement, TSelector>>;
55
- normalizeRegion(region: types.Region, shouldIgnoreSafeRegion?: boolean): Promise<types.Region>;
55
+ normalizeRegion(region: types.Region): Promise<types.Region>;
56
56
  getRegionInViewport(context: Context<TDriver, TContext, TElement, TSelector>, region: types.Region): Promise<types.Region>;
57
57
  element(selector: types.Selector<TSelector>): Promise<Element<TDriver, TContext, TElement, TSelector>>;
58
58
  elements(selector: types.Selector<TSelector>): Promise<Element<TDriver, TContext, TElement, TSelector>[]>;
@@ -31,7 +31,7 @@ export declare class Element<TDriver, TContext, TElement, TSelector> {
31
31
  get isRef(): boolean;
32
32
  equals(element: Element<TDriver, TContext, TElement, TSelector> | TElement): Promise<boolean>;
33
33
  init(context: Context<TDriver, TContext, TElement, TSelector>): Promise<this>;
34
- getRegion(shouldIgnoreSafeRegion?: boolean): Promise<types.Region>;
34
+ getRegion(): Promise<types.Region>;
35
35
  getClientRegion(): Promise<types.Region>;
36
36
  getContentSize(): Promise<types.Size>;
37
37
  isScrollable(): Promise<boolean>;