@applitools/driver 1.18.0 → 1.19.1

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,38 @@
1
1
  # Changelog
2
2
 
3
+ ## [1.19.1](https://github.com/Applitools-Dev/sdk/compare/js/driver@1.19.0...js/driver@1.19.1) (2024-09-16)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * stale layout breakpoints elements ([#2479](https://github.com/Applitools-Dev/sdk/issues/2479)) ([f5e4b5a](https://github.com/Applitools-Dev/sdk/commit/f5e4b5ac8077b8c4b7ba67a38c4e58050a55ce75))
9
+
10
+
11
+ ### Dependencies
12
+
13
+ * @applitools/snippets bumped to 2.5.0
14
+ #### Features
15
+
16
+ * add playwright fixture ([#2412](https://github.com/Applitools-Dev/sdk/issues/2412)) ([0632e93](https://github.com/Applitools-Dev/sdk/commit/0632e93dd7f53029a8c5f4230d22a05abf5fefd4))
17
+
18
+
19
+ #### Bug Fixes
20
+
21
+ * stale layout breakpoints elements ([#2479](https://github.com/Applitools-Dev/sdk/issues/2479)) ([f5e4b5a](https://github.com/Applitools-Dev/sdk/commit/f5e4b5ac8077b8c4b7ba67a38c4e58050a55ce75))
22
+
23
+ ## [1.19.0](https://github.com/Applitools-Dev/sdk/compare/js/driver@1.18.0...js/driver@1.19.0) (2024-09-10)
24
+
25
+
26
+ ### Features
27
+
28
+ * 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))
29
+
30
+
31
+ ### Bug Fixes
32
+
33
+ * handle userAgent.brands returned as string ([#2453](https://github.com/Applitools-Dev/sdk/issues/2453)) ([dd6328b](https://github.com/Applitools-Dev/sdk/commit/dd6328be3e7d885714124a8e43aabaae3abecde9))
34
+ * searching for scrollable element multiple times ([#2493](https://github.com/Applitools-Dev/sdk/issues/2493)) ([d98db80](https://github.com/Applitools-Dev/sdk/commit/d98db8016c6312f467f244444c6f1a87bc09b7da))
35
+
3
36
  ## [1.18.0](https://github.com/Applitools-Dev/sdk/compare/js/driver@1.17.5...js/driver@1.18.0) (2024-07-23)
4
37
 
5
38
 
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
@@ -284,7 +284,10 @@ class Driver {
284
284
  this._environment.isEmulation = true;
285
285
  }
286
286
  const driverUrl = (_d = (await this.getDriverUrl())) !== null && _d !== void 0 ? _d : '';
287
- 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);
288
291
  this._environment.isKobiton = /kobiton/.test(driverUrl);
289
292
  this._logger.log('Extracted environment', this._environment);
290
293
  }
@@ -142,16 +142,12 @@ class MockDriver {
142
142
  this.mockScript(snippets.blurElement, () => {
143
143
  return null;
144
144
  });
145
- this.mockScript(snippets.addElementIds, ([elements, ids]) => {
146
- const selectors = [];
147
- for (const [index, element] of elements.entries()) {
148
- const elementId = ids[index];
145
+ this.mockScript(snippets.addElementIds, elementsWithIds => {
146
+ return elementsWithIds.map(([elements, id]) => elements.map(element => {
149
147
  element.attributes = element.attributes || [];
150
- element.attributes.push({ name: 'data-applitools-selector', value: elementId });
151
- const selector = `[data-applitools-selector~="${elementId}"]`;
152
- selectors.push([selector]);
153
- }
154
- return selectors;
148
+ element.attributes.push({ name: 'data-applitools-marker', value: id });
149
+ return [`[data-applitools-marker~="${id}"]`]; // no shadow is mocked here
150
+ }));
155
151
  });
156
152
  this.mockScript(snippets.cleanupElementIds, ([elements]) => {
157
153
  for (const el of elements) {
@@ -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.18.0",
3
+ "version": "1.19.1",
4
4
  "description": "Applitools universal framework wrapper",
5
5
  "keywords": [
6
6
  "applitools",
@@ -74,7 +74,7 @@
74
74
  },
75
75
  "dependencies": {
76
76
  "@applitools/logger": "2.0.18",
77
- "@applitools/snippets": "2.4.27",
77
+ "@applitools/snippets": "2.5.0",
78
78
  "@applitools/utils": "1.7.4",
79
79
  "semver": "7.6.2"
80
80
  },
@@ -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>;