@applitools/driver 1.9.26 → 1.9.28

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,41 +1,31 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.parseCapabilities = void 0;
4
- function parseCapabilities(capabilities, customConfig) {
5
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
4
+ function parseCapabilities(capabilities) {
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
- }
18
8
  const info = {
19
9
  browserName: !capabilities.app && !capabilities.bundleId
20
- ? ((_c = capabilities.browserName) !== null && _c !== void 0 ? _c : (_d = capabilities.desired) === null || _d === void 0 ? void 0 : _d.browserName) || undefined
10
+ ? ((_a = capabilities.browserName) !== null && _a !== void 0 ? _a : (_b = capabilities.desired) === null || _b === void 0 ? void 0 : _b.browserName) || undefined
21
11
  : 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,
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,
24
14
  platformVersion: capabilities.platformVersion || undefined,
25
15
  isW3C: isW3C(capabilities),
26
16
  isMobile: isMobile(capabilities),
27
17
  };
28
18
  if (info.isMobile) {
29
- info.deviceName = ((_k = (_j = capabilities.desired) === null || _j === void 0 ? void 0 : _j.deviceName) !== null && _k !== void 0 ? _k : capabilities.deviceName) || undefined;
19
+ info.deviceName = ((_h = (_g = capabilities.desired) === null || _g === void 0 ? void 0 : _g.deviceName) !== null && _h !== void 0 ? _h : capabilities.deviceName) || undefined;
30
20
  info.isNative = info.isMobile && !info.browserName;
31
21
  info.isIOS = isIOS(capabilities);
32
22
  info.isAndroid = isAndroid(capabilities);
33
- info.orientation = (_m = ((_l = capabilities.deviceOrientation) !== null && _l !== void 0 ? _l : capabilities.orientation)) === null || _m === void 0 ? void 0 : _m.toLowerCase();
23
+ info.orientation = (_k = ((_j = capabilities.deviceOrientation) !== null && _j !== void 0 ? _j : capabilities.orientation)) === null || _k === void 0 ? void 0 : _k.toLowerCase();
34
24
  }
35
25
  if (info.isNative) {
36
26
  info.displaySize = extractDisplaySize(capabilities);
37
27
  info.pixelRatio = capabilities.pixelRatio;
38
- info.statusBarSize = (_o = capabilities.statBarHeight) !== null && _o !== void 0 ? _o : (_p = capabilities.viewportRect) === null || _p === void 0 ? void 0 : _p.top;
28
+ info.statusBarSize = (_l = capabilities.statBarHeight) !== null && _l !== void 0 ? _l : (_m = capabilities.viewportRect) === null || _m === void 0 ? void 0 : _m.top;
39
29
  if (info.displaySize && info.orientation && capabilities.viewportRect) {
40
30
  info.navigationBarSize =
41
31
  info.orientation === 'landscape'
package/dist/driver.js CHANGED
@@ -23,7 +23,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
23
23
  return result;
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.Driver = void 0;
26
+ exports.makeDriver = exports.Driver = void 0;
27
27
  const logger_1 = require("@applitools/logger");
28
28
  const utils = __importStar(require("@applitools/utils"));
29
29
  const specUtils = __importStar(require("./spec-utils"));
@@ -148,7 +148,7 @@ class Driver {
148
148
  var _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15;
149
149
  const capabilities = await ((_b = (_a = this._spec).getCapabilities) === null || _b === void 0 ? void 0 : _b.call(_a, this.target));
150
150
  this._logger.log('Driver capabilities', capabilities);
151
- const capabilitiesInfo = capabilities ? (0, capabilities_1.parseCapabilities)(capabilities, this._customConfig) : undefined;
151
+ const capabilitiesInfo = capabilities ? (0, capabilities_1.parseCapabilities)(capabilities) : undefined;
152
152
  const driverInfo = await ((_d = (_c = this._spec).getDriverInfo) === null || _d === void 0 ? void 0 : _d.call(_c, this.target));
153
153
  this._driverInfo = { ...capabilitiesInfo, ...driverInfo };
154
154
  if (this.isMobile) {
@@ -619,3 +619,10 @@ class Driver {
619
619
  }
620
620
  }
621
621
  exports.Driver = Driver;
622
+ async function makeDriver(options) {
623
+ const driver = new Driver(options);
624
+ await driver.init();
625
+ await driver.refreshContexts();
626
+ return driver;
627
+ }
628
+ exports.makeDriver = makeDriver;
@@ -34,6 +34,7 @@ exports.isSimpleCommonSelector = isSimpleCommonSelector;
34
34
  function isCommonSelector(spec, selector) {
35
35
  return (utils.types.isPlainObject(selector) &&
36
36
  utils.types.has(selector, 'selector') &&
37
+ Object.keys(selector).every(key => ['selector', 'type', 'frame', 'shadow'].includes(key)) &&
37
38
  (utils.types.isString(selector.selector) || spec.isSelector(selector.selector)));
38
39
  }
39
40
  exports.isCommonSelector = isCommonSelector;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@applitools/driver",
3
- "version": "1.9.26",
3
+ "version": "1.9.28",
4
4
  "description": "Applitools universal framework wrapper",
5
5
  "keywords": [
6
6
  "applitools",
@@ -40,9 +40,18 @@
40
40
  "types": "./types/debug/index.d.ts",
41
41
  "default": "./dist/debug/index.js"
42
42
  },
43
- "./dist/*": "./dist/*.js",
44
- "./dist/fake": "./dist/fake/index.js",
45
- "./dist/debug": "./dist/debug/index.js",
43
+ "./dist/*": {
44
+ "types": "./types/*.d.ts",
45
+ "default": "./dist/*.js"
46
+ },
47
+ "./dist/fake": {
48
+ "types": "./types/fake/index.d.ts",
49
+ "default": "./dist/fake/index.js"
50
+ },
51
+ "./dist/debug": {
52
+ "types": "./types/debug/index.d.ts",
53
+ "default": "./dist/debug/index.js"
54
+ },
46
55
  "./package.json": "./package.json"
47
56
  },
48
57
  "main": "./dist/index.js",
@@ -78,10 +87,10 @@
78
87
  }
79
88
  },
80
89
  "dependencies": {
81
- "@applitools/logger": "1.1.16",
90
+ "@applitools/logger": "1.1.20",
82
91
  "@applitools/snippets": "2.4.5",
83
- "@applitools/types": "1.5.9",
84
- "@applitools/utils": "1.3.10",
92
+ "@applitools/types": "1.5.13",
93
+ "@applitools/utils": "1.3.12",
85
94
  "semver": "7.3.7"
86
95
  },
87
96
  "devDependencies": {
@@ -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, customConfig?: types.CustomCapabilitiesConfig): types.DriverInfo;
3
+ export declare function parseCapabilities(capabilities: Capabilities): types.DriverInfo;
4
4
  export {};
package/types/driver.d.ts CHANGED
@@ -5,6 +5,12 @@ import { Context, ContextReference } from './context';
5
5
  import { Element } from './element';
6
6
  import { HelperIOS } from './helper-ios';
7
7
  import { HelperAndroid } from './helper-android';
8
+ declare type DriverOptions<TDriver, TContext, TElement, TSelector> = {
9
+ spec: types.SpecDriver<TDriver, TContext, TElement, TSelector>;
10
+ driver: Driver<TDriver, TContext, TElement, TSelector> | TDriver;
11
+ logger?: Logger;
12
+ customConfig?: types.CustomDriverConfig;
13
+ };
8
14
  export declare class Driver<TDriver, TContext, TElement, TSelector> {
9
15
  private _target;
10
16
  private _mainContext;
@@ -14,12 +20,7 @@ export declare class Driver<TDriver, TContext, TElement, TSelector> {
14
20
  private _customConfig;
15
21
  private _helper?;
16
22
  protected readonly _spec: types.SpecDriver<TDriver, TContext, TElement, TSelector>;
17
- constructor(options: {
18
- spec: types.SpecDriver<TDriver, TContext, TElement, TSelector>;
19
- driver: Driver<TDriver, TContext, TElement, TSelector> | TDriver;
20
- logger?: Logger;
21
- customConfig?: types.CustomDriverConfig;
22
- });
23
+ constructor(options: DriverOptions<TDriver, TContext, TElement, TSelector>);
23
24
  get target(): TDriver;
24
25
  get currentContext(): Context<TDriver, TContext, TElement, TSelector>;
25
26
  get mainContext(): Context<TDriver, TContext, TElement, TSelector>;
@@ -70,3 +71,5 @@ export declare class Driver<TDriver, TContext, TElement, TSelector> {
70
71
  getUrl(): Promise<string>;
71
72
  visit(url: string): Promise<void>;
72
73
  }
74
+ export declare function makeDriver<TDriver, TContext, TElement, TSelector>(options: DriverOptions<TDriver, TContext, TElement, TSelector>): Promise<Driver<TDriver, TContext, TElement, TSelector>>;
75
+ export {};
@@ -40,7 +40,11 @@ export declare class Element<TDriver, TContext, TElement, TSelector> {
40
40
  getRegion(): Promise<types.Region>;
41
41
  getClientRegion(): Promise<types.Region>;
42
42
  getContentSize(options?: {
43
- lazyLoad?: types.LazyLoadOptions;
43
+ lazyLoad?: {
44
+ scrollLength?: number;
45
+ waitingTime?: number;
46
+ maxAmountToScroll?: number;
47
+ };
44
48
  }): Promise<types.Size>;
45
49
  isPager(): Promise<boolean>;
46
50
  isScrollable(): Promise<boolean>;
@@ -21,7 +21,7 @@ export declare class MockDriver {
21
21
  };
22
22
  executeScript(script: any, args?: any[]): Promise<any>;
23
23
  findElement(selector: any, rootElement?: any): Promise<any>;
24
- findElements(selector: any, rootElement: any): Promise<any>;
24
+ findElements(selector: any, rootElement?: any): Promise<any>;
25
25
  switchToFrame(reference: any): Promise<this>;
26
26
  switchToParentFrame(): Promise<this>;
27
27
  getWindowRect(): Promise<any>;
@@ -7,7 +7,7 @@ export declare type Selector = string | {
7
7
  value: string;
8
8
  };
9
9
  declare type CommonSelector = string | {
10
- selector: Selector | string;
10
+ selector: string;
11
11
  type?: string;
12
12
  };
13
13
  export declare function isDriver(driver: any): driver is Driver;
@@ -26,7 +26,11 @@ export declare class HelperAndroid<TDriver, TContext, TElement, TSelector> {
26
26
  private _getElementId;
27
27
  private _command;
28
28
  getContentRegion(element: Element<TDriver, TContext, TElement, TSelector>, options?: {
29
- lazyLoad?: types.LazyLoadOptions;
29
+ lazyLoad?: {
30
+ scrollLength?: number;
31
+ waitingTime?: number;
32
+ maxAmountToScroll?: number;
33
+ };
30
34
  }): Promise<types.Region>;
31
35
  getTouchPadding(): Promise<number>;
32
36
  getRegion(element: Element<TDriver, TContext, TElement, TSelector>): Promise<types.Region>;