@applitools/driver 1.13.0 → 1.13.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,29 @@
1
1
  # Changelog
2
2
 
3
+ ## [1.13.2](https://github.com/applitools/eyes.sdk.javascript1/compare/js/driver@1.13.1...js/driver@1.13.2) (2023-07-21)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * improve performance by not resetting the environment ([#1779](https://github.com/applitools/eyes.sdk.javascript1/issues/1779)) ([8178978](https://github.com/applitools/eyes.sdk.javascript1/commit/8178978e9443e60f3e8b10693395e4c80cb9e02f))
9
+
10
+
11
+ ### Code Refactoring
12
+
13
+ * ufg client ([#1780](https://github.com/applitools/eyes.sdk.javascript1/issues/1780)) ([d60cf16](https://github.com/applitools/eyes.sdk.javascript1/commit/d60cf1616741a96b152a1548760bb98116e5c3f9))
14
+
15
+
16
+ ### Dependencies
17
+
18
+
19
+
20
+ ## [1.13.1](https://github.com/applitools/eyes.sdk.javascript1/compare/js/driver@1.13.0...js/driver@1.13.1) (2023-07-13)
21
+
22
+
23
+ ### Bug Fixes
24
+
25
+ * replaced NML prefixed appium env vars with APPLITOOLS prefixed ([8905b90](https://github.com/applitools/eyes.sdk.javascript1/commit/8905b90e7c4ec6e310f6e52c03bbcc7acf1ff2ab))
26
+
3
27
  ## [1.13.0](https://github.com/applitools/eyes.sdk.javascript1/compare/js/driver@1.12.4...js/driver@1.13.0) (2023-07-05)
4
28
 
5
29
 
@@ -52,12 +52,12 @@ function extractCapabilitiesEnvironment(capabilities) {
52
52
  if (!environment.browserName) {
53
53
  environment.isNative = true;
54
54
  if (environment.isAndroid) {
55
- environment.isApplitoolsLib = !!((_t = capabilities.optionalIntentArguments) === null || _t === void 0 ? void 0 : _t.includes('NML_API_KEY'));
55
+ environment.isApplitoolsLib = !!((_t = capabilities.optionalIntentArguments) === null || _t === void 0 ? void 0 : _t.includes('APPLITOOLS_API_KEY'));
56
56
  }
57
57
  else if (environment.isIOS) {
58
58
  environment.isApplitoolsLib = utils.types.isString(capabilities.processArguments)
59
- ? capabilities.processArguments.includes('NML_API_KEY')
60
- : !!((_v = (_u = capabilities.processArguments) === null || _u === void 0 ? void 0 : _u.env) === null || _v === void 0 ? void 0 : _v.NML_API_KEY);
59
+ ? capabilities.processArguments.includes('APPLITOOLS_API_KEY')
60
+ : !!((_v = (_u = capabilities.processArguments) === null || _u === void 0 ? void 0 : _u.env) === null || _v === void 0 ? void 0 : _v.APPLITOOLS_API_KEY);
61
61
  }
62
62
  }
63
63
  else if (environment.isIOS &&
package/dist/driver.js CHANGED
@@ -38,6 +38,7 @@ class Driver {
38
38
  var _a, _b, _c, _d, _e, _f, _g;
39
39
  this._state = {};
40
40
  this._customConfig = {};
41
+ this._original = this;
41
42
  this._logger = (0, logger_1.makeLogger)({ logger: options.logger, format: { label: 'driver' } });
42
43
  this._customConfig = (_a = options.customConfig) !== null && _a !== void 0 ? _a : {};
43
44
  this._guid = utils.general.guid();
@@ -76,15 +77,17 @@ class Driver {
76
77
  }
77
78
  async reloadPage() {
78
79
  await this.mainContext.execute(snippets.reloadPage).catch(() => null);
79
- return this.refresh();
80
- }
81
- async refresh() {
82
- this._driverInfo = undefined;
83
- this._environment = undefined;
84
- this._viewport = undefined;
85
- this._features = undefined;
86
- this._helper = undefined;
87
- this._state = {};
80
+ return this.refresh({ reset: false });
81
+ }
82
+ async refresh({ reset } = {}) {
83
+ if (reset) {
84
+ this._driverInfo = undefined;
85
+ this._environment = undefined;
86
+ this._viewport = undefined;
87
+ this._features = undefined;
88
+ this._helper = undefined;
89
+ this._state = {};
90
+ }
88
91
  const spec = this._spec;
89
92
  let currentContext = this.currentContext.target;
90
93
  let contextInfo;
@@ -92,7 +95,7 @@ class Driver {
92
95
  contextInfo = await getContextInfo(currentContext);
93
96
  }
94
97
  catch (err) {
95
- return this;
98
+ return reset ? resetReference(this) : this;
96
99
  }
97
100
  const path = [];
98
101
  if (spec.parentContext) {
@@ -111,7 +114,16 @@ class Driver {
111
114
  }
112
115
  this._currentContext = this._mainContext;
113
116
  await this.switchToChildContext(...path);
114
- return this;
117
+ return reset ? resetReference(this) : this;
118
+ function resetReference(driver) {
119
+ return new Proxy(driver._original, {
120
+ get(driver, key, receiver) {
121
+ if (key === '_original')
122
+ return driver;
123
+ return Reflect.get(driver, key, receiver);
124
+ },
125
+ });
126
+ }
115
127
  function transformSelector(selector) {
116
128
  return specUtils.transformSelector(spec, selector, { isWeb: true });
117
129
  }
@@ -188,7 +200,11 @@ class Driver {
188
200
  var _f;
189
201
  if (((_a = this._driverInfo) === null || _a === void 0 ? void 0 : _a.userAgent) === undefined || force) {
190
202
  (_b = this._driverInfo) !== null && _b !== void 0 ? _b : (this._driverInfo = {});
191
- (_c = (_f = this._driverInfo).userAgent) !== null && _c !== void 0 ? _c : (_f.userAgent = (_d = (await this.currentContext.executePoll(snippets.getUserAgent))) !== null && _d !== void 0 ? _d : null);
203
+ (_c = (_f = this._driverInfo).userAgent) !== null && _c !== void 0 ? _c : (_f.userAgent = (_d = (await this.currentContext.executePoll(snippets.getUserAgent, {
204
+ main: undefined,
205
+ poll: undefined,
206
+ pollTimeout: 100,
207
+ }))) !== null && _d !== void 0 ? _d : null);
192
208
  this._logger.log('Extracted user agent', this._driverInfo.userAgent);
193
209
  }
194
210
  return (_e = this._driverInfo.userAgent) !== null && _e !== void 0 ? _e : undefined;
@@ -493,7 +509,7 @@ class Driver {
493
509
  }
494
510
  try {
495
511
  await this._spec.switchWorld(this.target, name);
496
- this.refresh();
512
+ this.refresh({ reset: true });
497
513
  }
498
514
  catch (error) {
499
515
  this._logger.error('Unable to switch world due to the error', error);
@@ -813,6 +829,6 @@ async function makeDriver(options) {
813
829
  const driver = options.driver instanceof Driver ? options.driver : new Driver(options);
814
830
  if (options.logger)
815
831
  driver.updateLogger(options.logger);
816
- return driver.refresh();
832
+ return driver.refresh({ reset: options.reset });
817
833
  }
818
834
  exports.makeDriver = makeDriver;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@applitools/driver",
3
- "version": "1.13.0",
3
+ "version": "1.13.2",
4
4
  "description": "Applitools universal framework wrapper",
5
5
  "keywords": [
6
6
  "applitools",
@@ -73,10 +73,10 @@
73
73
  "test": "run --top-level mocha './test/**/*.spec.ts'"
74
74
  },
75
75
  "dependencies": {
76
- "@applitools/logger": "2.0.5",
77
- "@applitools/snippets": "2.4.21",
78
- "@applitools/utils": "1.5.0",
79
- "semver": "7.3.7"
76
+ "@applitools/logger": "2.0.6",
77
+ "@applitools/snippets": "",
78
+ "@applitools/utils": "",
79
+ "semver": "7.5.4"
80
80
  },
81
81
  "devDependencies": {
82
82
  "@types/node": "^12.20.55"
package/types/driver.d.ts CHANGED
@@ -30,6 +30,7 @@ export declare class Driver<T extends SpecType> {
30
30
  private _customConfig;
31
31
  private _logger;
32
32
  protected readonly _spec: SpecDriver<T>;
33
+ protected readonly _original: this;
33
34
  constructor(options: DriverOptions<T>);
34
35
  get logger(): Logger;
35
36
  get target(): T['driver'];
@@ -39,7 +40,9 @@ export declare class Driver<T extends SpecType> {
39
40
  updateLogger(logger: Logger): void;
40
41
  updateCurrentContext(context: Context<T>): void;
41
42
  reloadPage(): Promise<this>;
42
- refresh(): Promise<this>;
43
+ refresh({ reset }?: {
44
+ reset?: boolean;
45
+ }): Promise<this>;
43
46
  getDriverInfo({ force }?: {
44
47
  force?: boolean;
45
48
  }): Promise<DriverInfo>;
@@ -91,6 +94,7 @@ export declare function makeDriver<T extends SpecType>(options: {
91
94
  customConfig?: {
92
95
  useCeilForViewportSize?: boolean;
93
96
  };
97
+ reset?: boolean;
94
98
  logger?: Logger;
95
99
  }): Promise<Driver<T>>;
96
100
  export {};