@applitools/driver 1.17.5 → 1.19.0

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,30 @@
1
1
  # Changelog
2
2
 
3
+ ## [1.19.0](https://github.com/Applitools-Dev/sdk/compare/js/driver@1.18.0...js/driver@1.19.0) (2024-09-10)
4
+
5
+
6
+ ### Features
7
+
8
+ * add support for env var APPLITOOLS_IS_IC ([#2469](https://github.com/Applitools-Dev/sdk/issues/2469)) ([87d7b5c](https://github.com/Applitools-Dev/sdk/commit/87d7b5cc1f7ea774c6b90504e85296f0681d0b1e))
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * handle userAgent.brands returned as string ([#2453](https://github.com/Applitools-Dev/sdk/issues/2453)) ([dd6328b](https://github.com/Applitools-Dev/sdk/commit/dd6328be3e7d885714124a8e43aabaae3abecde9))
14
+ * searching for scrollable element multiple times ([#2493](https://github.com/Applitools-Dev/sdk/issues/2493)) ([d98db80](https://github.com/Applitools-Dev/sdk/commit/d98db8016c6312f467f244444c6f1a87bc09b7da))
15
+
16
+ ## [1.18.0](https://github.com/Applitools-Dev/sdk/compare/js/driver@1.17.5...js/driver@1.18.0) (2024-07-23)
17
+
18
+
19
+ ### Features
20
+
21
+ * disable broker url cache ([#2428](https://github.com/Applitools-Dev/sdk/issues/2428)) ([cb8d5fe](https://github.com/Applitools-Dev/sdk/commit/cb8d5fefb13d3ab42984d2bd4d4ac3d4e10646b0))
22
+
23
+
24
+ ### Bug Fixes
25
+
26
+ * executing web script on mobile environment ([#2380](https://github.com/Applitools-Dev/sdk/issues/2380)) ([da2e551](https://github.com/Applitools-Dev/sdk/commit/da2e551e01082d3cc21b9da5b43e6680233c080d))
27
+
3
28
  ## [1.17.5](https://github.com/Applitools-Dev/sdk/compare/js/driver@1.17.4...js/driver@1.17.5) (2024-06-26)
4
29
 
5
30
 
package/dist/context.js CHANGED
@@ -38,6 +38,13 @@ class Context {
38
38
  constructor(options) {
39
39
  var _a, _b, _c, _d;
40
40
  this._state = {};
41
+ /**
42
+ * The purpose of this state is to make sure we don't search for the SRE multiple times.
43
+ * This is unwanted to have but needed, search for `.setScrollingElement(settings.scrollRootElement ?? null)`,
44
+ * I don't want to risk breaking it.
45
+ * e.g in js/packages/core/src/classic/check.ts
46
+ */
47
+ this._searchScrollingElement = true;
41
48
  this._spec = options.spec;
42
49
  if (options.context) {
43
50
  if ((_c = (_b = (_a = this._spec).isContext) === null || _b === void 0 ? void 0 : _b.call(_a, options.context)) !== null && _c !== void 0 ? _c : this._spec.isDriver(options.context)) {
@@ -392,6 +399,8 @@ class Context {
392
399
  return (_a = this._element) !== null && _a !== void 0 ? _a : null;
393
400
  }
394
401
  async getScrollingElement() {
402
+ if (!this._searchScrollingElement)
403
+ return this._scrollingElement;
395
404
  if (!(0, element_1.isElementInstance)(this._scrollingElement)) {
396
405
  await this.focus();
397
406
  if (this._scrollingElement) {
@@ -415,6 +424,9 @@ class Context {
415
424
  this._scrollingElement = await this.element({ type: 'xpath', selector: '//*[@scrollable="true"]' });
416
425
  }
417
426
  }
427
+ if (this._scrollingElement === null) {
428
+ this._searchScrollingElement = false;
429
+ }
418
430
  }
419
431
  return this._scrollingElement;
420
432
  }
package/dist/driver.js CHANGED
@@ -89,7 +89,7 @@ class Driver {
89
89
  await (scrollingElement === null || scrollingElement === void 0 ? void 0 : scrollingElement.refresh());
90
90
  return refreshThis;
91
91
  }
92
- async refresh({ reset } = {}) {
92
+ async refresh({ reset, name } = {}) {
93
93
  if (reset) {
94
94
  if (utils.general.getEnvValue('AVOID_DRIVER_STATE_REST', 'boolean')) {
95
95
  this._logger.log(`Skipping reset of the driver state`);
@@ -103,6 +103,9 @@ class Driver {
103
103
  this._state = {};
104
104
  }
105
105
  }
106
+ if (name === 'NATIVE_APP') {
107
+ return reset ? resetReference(this) : this;
108
+ }
106
109
  const spec = this._spec;
107
110
  let currentContext = this.currentContext.target;
108
111
  let contextInfo;
@@ -281,7 +284,10 @@ class Driver {
281
284
  this._environment.isEmulation = true;
282
285
  }
283
286
  const driverUrl = (_d = (await this.getDriverUrl())) !== null && _d !== void 0 ? _d : '';
284
- this._environment.isEC = this._environment.isECClient || /exec-wus.applitools.com/.test(driverUrl);
287
+ this._environment.isEC =
288
+ this._environment.isECClient ||
289
+ utils.general.getEnvValue('IS_EC', 'boolean') ||
290
+ /exec-wus\.applitools\.com/.test(driverUrl);
285
291
  this._environment.isKobiton = /kobiton/.test(driverUrl);
286
292
  this._logger.log('Extracted environment', this._environment);
287
293
  }
@@ -538,7 +544,7 @@ class Driver {
538
544
  }
539
545
  try {
540
546
  await this._spec.switchWorld(this.target, name);
541
- await this.refresh({ reset: true });
547
+ await this.refresh({ reset: true, name });
542
548
  }
543
549
  catch (error) {
544
550
  this._logger.error('Unable to switch world due to the error', error);
@@ -143,9 +143,18 @@ function extractUserAgentLegacyBrowser(userAgent) {
143
143
  };
144
144
  }
145
145
  function extractUserAgentObjectEnvironment(userAgent) {
146
- var _a, _b, _c, _d;
147
- const chromiumBrand = (_a = userAgent.brands) === null || _a === void 0 ? void 0 : _a.find(brand => /Chromium/i.test(brand.brand));
148
- const browserBrand = (_c = (_b = userAgent.brands) === null || _b === void 0 ? void 0 : _b.find(brand => brand !== chromiumBrand && !/Not.?A.?Brand/i.test(brand.brand))) !== null && _c !== void 0 ? _c : chromiumBrand;
146
+ var _a, _b, _c, _d, _e, _f;
147
+ if (typeof userAgent.brands === 'string') {
148
+ try {
149
+ userAgent.brands = JSON.parse(userAgent.brands);
150
+ }
151
+ catch (e) {
152
+ userAgent.brands = [];
153
+ }
154
+ }
155
+ // we assume the structure of the brands array, but since it's an experimental API, we use optional chaining to stay on the safe side
156
+ const chromiumBrand = (_b = (_a = userAgent.brands) === null || _a === void 0 ? void 0 : _a.find) === null || _b === void 0 ? void 0 : _b.call(_a, brand => /Chromium/i.test(brand.brand));
157
+ const browserBrand = (_e = (_d = (_c = userAgent.brands) === null || _c === void 0 ? void 0 : _c.find) === null || _d === void 0 ? void 0 : _d.call(_c, brand => brand !== chromiumBrand && !/Not.?A.?Brand/i.test(brand.brand))) !== null && _e !== void 0 ? _e : chromiumBrand;
149
158
  const environment = {
150
159
  browserName: browserBrand === null || browserBrand === void 0 ? void 0 : browserBrand.brand,
151
160
  browserVersion: browserBrand === null || browserBrand === void 0 ? void 0 : browserBrand.version,
@@ -161,7 +170,7 @@ function extractUserAgentObjectEnvironment(userAgent) {
161
170
  }
162
171
  else if (environment.platformName === 'macOS') {
163
172
  environment.platformName = 'Mac OS X';
164
- environment.platformVersion = (_d = environment.platformVersion) === null || _d === void 0 ? void 0 : _d.split(/[._]/, 2).join('.');
173
+ environment.platformVersion = (_f = environment.platformVersion) === null || _f === void 0 ? void 0 : _f.split(/[._]/, 2).join('.');
165
174
  }
166
175
  return environment;
167
176
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@applitools/driver",
3
- "version": "1.17.5",
3
+ "version": "1.19.0",
4
4
  "description": "Applitools universal framework wrapper",
5
5
  "keywords": [
6
6
  "applitools",
@@ -29,6 +29,13 @@ export declare class Context<T extends SpecType> {
29
29
  private _state;
30
30
  private _isReference;
31
31
  protected readonly _spec: SpecDriver<T>;
32
+ /**
33
+ * The purpose of this state is to make sure we don't search for the SRE multiple times.
34
+ * This is unwanted to have but needed, search for `.setScrollingElement(settings.scrollRootElement ?? null)`,
35
+ * I don't want to risk breaking it.
36
+ * e.g in js/packages/core/src/classic/check.ts
37
+ */
38
+ private _searchScrollingElement;
32
39
  constructor(options: ContextOptions<T>);
33
40
  get logger(): import("@applitools/logger").Logger;
34
41
  get target(): T['driver'];
@@ -59,7 +66,7 @@ export declare class Context<T extends SpecType> {
59
66
  pollTimeout?: number;
60
67
  }): Promise<any>;
61
68
  getContextElement(): Promise<Element<T> | null>;
62
- getScrollingElement(): Promise<Element<T> | null>;
69
+ getScrollingElement(): Promise<Element<T> | null | undefined>;
63
70
  setScrollingElement(scrollingElement: Element<T> | ElementReference<T> | undefined | null): Promise<void>;
64
71
  blurElement(element?: Element<T>): Promise<T['element'] | null>;
65
72
  focusElement(element: Element<T>): Promise<any>;
package/types/driver.d.ts CHANGED
@@ -32,14 +32,15 @@ export declare class Driver<T extends SpecType> {
32
32
  constructor(options: DriverOptions<T>);
33
33
  get logger(): Logger;
34
34
  get target(): T['driver'];
35
- get guid(): string | undefined;
35
+ get guid(): string;
36
36
  get currentContext(): Context<T>;
37
37
  get mainContext(): Context<T>;
38
38
  updateLogger(logger: Logger): void;
39
39
  updateCurrentContext(context: Context<T>): void;
40
40
  reloadPage(): Promise<this>;
41
- refresh({ reset }?: {
41
+ refresh({ reset, name }?: {
42
42
  reset?: boolean;
43
+ name?: string;
43
44
  }): Promise<this>;
44
45
  getDriverInfo({ force }?: {
45
46
  force?: boolean;