@applitools/driver 1.11.25 → 1.11.26

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.
@@ -15,7 +15,7 @@ function parseCapabilities(capabilities) {
15
15
  isW3C: isW3C(capabilities),
16
16
  isMobile: isMobile(capabilities),
17
17
  isChrome: isChrome(capabilities),
18
- isExecutionGridClient: Boolean(capabilities.applitools),
18
+ isECClient: Boolean(capabilities['applitools:isECClient']),
19
19
  };
20
20
  if (info.isMobile) {
21
21
  info.deviceName = ((_h = (_g = capabilities.desired) === null || _g === void 0 ? void 0 : _g.deviceName) !== null && _h !== void 0 ? _h : capabilities.deviceName) || undefined;
package/dist/driver.js CHANGED
@@ -159,26 +159,27 @@ class Driver {
159
159
  get isEdgeLegacy() {
160
160
  return /edge/i.test(this.browserName) && Number(this.browserVersion) <= 44;
161
161
  }
162
+ get isECClient() {
163
+ var _a;
164
+ return !!((_a = this._driverInfo) === null || _a === void 0 ? void 0 : _a.isECClient);
165
+ }
166
+ get isEC() {
167
+ return this.isECClient || (!!this.remoteHostname && /exec-wus.applitools.com/.test(this.remoteHostname));
168
+ }
162
169
  get sessionId() {
163
170
  var _a;
164
171
  return (_a = this._driverInfo) === null || _a === void 0 ? void 0 : _a.sessionId;
165
172
  }
166
- get isExecutionGridClient() {
173
+ get remoteHostname() {
167
174
  var _a;
168
- return !!((_a = this._driverInfo) === null || _a === void 0 ? void 0 : _a.isExecutionGridClient);
169
- }
170
- get isExecutionGrid() {
171
- var _a, _b;
172
- if (this.isExecutionGridClient)
173
- return true;
174
- return /exec-wus.applitools.com/.test((_b = (_a = this._spec) === null || _a === void 0 ? void 0 : _a.extractHostName) === null || _b === void 0 ? void 0 : _b.call(_a, this.target));
175
+ return (_a = this._driverInfo) === null || _a === void 0 ? void 0 : _a.remoteHostname;
175
176
  }
176
177
  updateCurrentContext(context) {
177
178
  this._currentContext = context;
178
179
  }
179
180
  async init() {
180
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18;
181
- var _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34;
181
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21;
182
+ var _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35, _36, _37, _38;
182
183
  // NOTE: this is here because saucelabs does not provide right capabilities for the first call
183
184
  await ((_b = (_a = this._spec).getCapabilities) === null || _b === void 0 ? void 0 : _b.call(_a, this.target));
184
185
  const capabilities = await ((_d = (_c = this._spec).getCapabilities) === null || _d === void 0 ? void 0 : _d.call(_c, this.target));
@@ -186,26 +187,27 @@ class Driver {
186
187
  const capabilitiesInfo = capabilities ? (0, capabilities_1.parseCapabilities)(capabilities) : undefined;
187
188
  const driverInfo = await ((_f = (_e = this._spec).getDriverInfo) === null || _f === void 0 ? void 0 : _f.call(_e, this.target));
188
189
  this._driverInfo = { ...capabilitiesInfo, ...driverInfo };
190
+ (_g = (_22 = this._driverInfo).remoteHostname) !== null && _g !== void 0 ? _g : (_22.remoteHostname = (_j = (_h = this._spec).extractHostName) === null || _j === void 0 ? void 0 : _j.call(_h, this.target));
189
191
  if (this.isMobile) {
190
192
  this._driverInfo.orientation =
191
- (_g = (await this.getOrientation().catch(() => undefined))) !== null && _g !== void 0 ? _g : this._driverInfo.orientation;
193
+ (_k = (await this.getOrientation().catch(() => undefined))) !== null && _k !== void 0 ? _k : this._driverInfo.orientation;
192
194
  const world = await this.getCurrentWorld();
193
195
  this._driverInfo.isWebView = !!(world === null || world === void 0 ? void 0 : world.isWebView);
194
196
  }
195
197
  if (this.isWeb) {
196
198
  const browserInfo = await this.currentContext.executePoll(snippets.getBrowserInfo);
197
- (_h = (_19 = this._driverInfo).userAgent) !== null && _h !== void 0 ? _h : (_19.userAgent = browserInfo.userAgent);
198
- (_j = (_20 = this._driverInfo).pixelRatio) !== null && _j !== void 0 ? _j : (_20.pixelRatio = browserInfo.pixelRatio);
199
- (_k = (_21 = this._driverInfo).viewportScale) !== null && _k !== void 0 ? _k : (_21.viewportScale = browserInfo.viewportScale);
199
+ (_l = (_23 = this._driverInfo).userAgent) !== null && _l !== void 0 ? _l : (_23.userAgent = browserInfo.userAgent);
200
+ (_m = (_24 = this._driverInfo).pixelRatio) !== null && _m !== void 0 ? _m : (_24.pixelRatio = browserInfo.pixelRatio);
201
+ (_o = (_25 = this._driverInfo).viewportScale) !== null && _o !== void 0 ? _o : (_25.viewportScale = browserInfo.viewportScale);
200
202
  if (browserInfo.userAgentData) {
201
- (_l = (_22 = this._driverInfo).isMobile) !== null && _l !== void 0 ? _l : (_22.isMobile = this._driverInfo.isMobile);
202
- (_m = (_23 = this._driverInfo).isChromium) !== null && _m !== void 0 ? _m : (_23.isChromium = this._driverInfo.isChromium);
203
+ (_p = (_26 = this._driverInfo).isMobile) !== null && _p !== void 0 ? _p : (_26.isMobile = this._driverInfo.isMobile);
204
+ (_q = (_27 = this._driverInfo).isChromium) !== null && _q !== void 0 ? _q : (_27.isChromium = this._driverInfo.isChromium);
203
205
  if (this.isChromium) {
204
206
  if (this.isWindows && Number.parseInt(this.browserVersion) >= 107) {
205
- this._driverInfo.platformVersion = (_o = browserInfo.platformVersion) !== null && _o !== void 0 ? _o : this._driverInfo.platformVersion;
207
+ this._driverInfo.platformVersion = (_r = browserInfo.platformVersion) !== null && _r !== void 0 ? _r : this._driverInfo.platformVersion;
206
208
  }
207
209
  else if (this.isMac && Number.parseInt(this.browserVersion) >= 90) {
208
- this._driverInfo.platformVersion = (_p = browserInfo.platformVersion) !== null && _p !== void 0 ? _p : this._driverInfo.platformVersion;
210
+ this._driverInfo.platformVersion = (_s = browserInfo.platformVersion) !== null && _s !== void 0 ? _s : this._driverInfo.platformVersion;
209
211
  }
210
212
  }
211
213
  }
@@ -213,34 +215,34 @@ class Driver {
213
215
  const userAgentInfo = (0, user_agent_1.parseUserAgent)(this._driverInfo.userAgent);
214
216
  const userAgentDataInfo = browserInfo.userAgentData && (0, user_agent_data_1.parseUserAgentData)(browserInfo.userAgentData);
215
217
  this._driverInfo.browserName =
216
- (_r = (_q = userAgentInfo.browserName) !== null && _q !== void 0 ? _q : userAgentDataInfo === null || userAgentDataInfo === void 0 ? void 0 : userAgentDataInfo.browserName) !== null && _r !== void 0 ? _r : this._driverInfo.browserName;
218
+ (_u = (_t = userAgentInfo.browserName) !== null && _t !== void 0 ? _t : userAgentDataInfo === null || userAgentDataInfo === void 0 ? void 0 : userAgentDataInfo.browserName) !== null && _u !== void 0 ? _u : this._driverInfo.browserName;
217
219
  this._driverInfo.browserVersion =
218
- (_t = (_s = userAgentInfo.browserVersion) !== null && _s !== void 0 ? _s : userAgentDataInfo === null || userAgentDataInfo === void 0 ? void 0 : userAgentDataInfo.browserVersion) !== null && _t !== void 0 ? _t : this._driverInfo.browserVersion;
219
- (_u = (_24 = this._driverInfo).isMobile) !== null && _u !== void 0 ? _u : (_24.isMobile = userAgentDataInfo === null || userAgentDataInfo === void 0 ? void 0 : userAgentDataInfo.isMobile);
220
- (_v = (_25 = this._driverInfo).isChromium) !== null && _v !== void 0 ? _v : (_25.isChromium = userAgentDataInfo === null || userAgentDataInfo === void 0 ? void 0 : userAgentDataInfo.isChromium);
220
+ (_w = (_v = userAgentInfo.browserVersion) !== null && _v !== void 0 ? _v : userAgentDataInfo === null || userAgentDataInfo === void 0 ? void 0 : userAgentDataInfo.browserVersion) !== null && _w !== void 0 ? _w : this._driverInfo.browserVersion;
221
+ (_x = (_28 = this._driverInfo).isMobile) !== null && _x !== void 0 ? _x : (_28.isMobile = userAgentDataInfo === null || userAgentDataInfo === void 0 ? void 0 : userAgentDataInfo.isMobile);
222
+ (_y = (_29 = this._driverInfo).isChromium) !== null && _y !== void 0 ? _y : (_29.isChromium = userAgentDataInfo === null || userAgentDataInfo === void 0 ? void 0 : userAgentDataInfo.isChromium);
221
223
  if (this._driverInfo.isMobile) {
222
- (_w = (_26 = this._driverInfo).platformName) !== null && _w !== void 0 ? _w : (_26.platformName = (_x = userAgentDataInfo === null || userAgentDataInfo === void 0 ? void 0 : userAgentDataInfo.platformName) !== null && _x !== void 0 ? _x : userAgentInfo.platformName);
223
- (_y = (_27 = this._driverInfo).platformVersion) !== null && _y !== void 0 ? _y : (_27.platformVersion = (_z = userAgentDataInfo === null || userAgentDataInfo === void 0 ? void 0 : userAgentDataInfo.platformVersion) !== null && _z !== void 0 ? _z : userAgentInfo.platformVersion);
224
+ (_z = (_30 = this._driverInfo).platformName) !== null && _z !== void 0 ? _z : (_30.platformName = (_0 = userAgentDataInfo === null || userAgentDataInfo === void 0 ? void 0 : userAgentDataInfo.platformName) !== null && _0 !== void 0 ? _0 : userAgentInfo.platformName);
225
+ (_1 = (_31 = this._driverInfo).platformVersion) !== null && _1 !== void 0 ? _1 : (_31.platformVersion = (_2 = userAgentDataInfo === null || userAgentDataInfo === void 0 ? void 0 : userAgentDataInfo.platformVersion) !== null && _2 !== void 0 ? _2 : userAgentInfo.platformVersion);
224
226
  }
225
227
  else {
226
228
  this._driverInfo.platformName =
227
- (_1 = (_0 = userAgentDataInfo === null || userAgentDataInfo === void 0 ? void 0 : userAgentDataInfo.platformName) !== null && _0 !== void 0 ? _0 : userAgentInfo.platformName) !== null && _1 !== void 0 ? _1 : this._driverInfo.platformName;
229
+ (_4 = (_3 = userAgentDataInfo === null || userAgentDataInfo === void 0 ? void 0 : userAgentDataInfo.platformName) !== null && _3 !== void 0 ? _3 : userAgentInfo.platformName) !== null && _4 !== void 0 ? _4 : this._driverInfo.platformName;
228
230
  this._driverInfo.platformVersion =
229
- (_3 = (_2 = userAgentDataInfo === null || userAgentDataInfo === void 0 ? void 0 : userAgentDataInfo.platformVersion) !== null && _2 !== void 0 ? _2 : userAgentInfo.platformVersion) !== null && _3 !== void 0 ? _3 : this._driverInfo.platformVersion;
231
+ (_6 = (_5 = userAgentDataInfo === null || userAgentDataInfo === void 0 ? void 0 : userAgentDataInfo.platformVersion) !== null && _5 !== void 0 ? _5 : userAgentInfo.platformVersion) !== null && _6 !== void 0 ? _6 : this._driverInfo.platformVersion;
230
232
  }
231
233
  }
232
234
  if (!this.isMobile && (this.isAndroid || this.isIOS)) {
233
235
  this._driverInfo.isMobile = true;
234
236
  this._driverInfo.isEmulation = this._driverInfo.isChrome;
235
237
  }
236
- (_4 = (_28 = this._driverInfo).features) !== null && _4 !== void 0 ? _4 : (_28.features = {});
237
- (_5 = (_29 = this._driverInfo.features).allCookies) !== null && _5 !== void 0 ? _5 : (_29.allCookies = this._driverInfo.isChrome || (/chrome/i.test(this._driverInfo.browserName) && !this._driverInfo.isMobile));
238
+ (_7 = (_32 = this._driverInfo).features) !== null && _7 !== void 0 ? _7 : (_32.features = {});
239
+ (_8 = (_33 = this._driverInfo.features).allCookies) !== null && _8 !== void 0 ? _8 : (_33.allCookies = this._driverInfo.isChrome || (/chrome/i.test(this._driverInfo.browserName) && !this._driverInfo.isMobile));
238
240
  }
239
241
  else {
240
242
  // this value always excludes the height of the navigation bar, and sometimes it also excludes the height of the status bar
241
243
  let windowSize = await this._spec.getWindowSize(this.target);
242
- (_6 = (_30 = this._driverInfo).displaySize) !== null && _6 !== void 0 ? _6 : (_30.displaySize = windowSize);
243
- if (((_7 = this.orientation) === null || _7 === void 0 ? void 0 : _7.startsWith('landscape')) &&
244
+ (_9 = (_34 = this._driverInfo).displaySize) !== null && _9 !== void 0 ? _9 : (_34.displaySize = windowSize);
245
+ if (((_10 = this.orientation) === null || _10 === void 0 ? void 0 : _10.startsWith('landscape')) &&
244
246
  this._driverInfo.displaySize.height > this._driverInfo.displaySize.width) {
245
247
  this._driverInfo.displaySize = {
246
248
  width: this._driverInfo.displaySize.height,
@@ -249,14 +251,14 @@ class Driver {
249
251
  }
250
252
  if (this.isAndroid) {
251
253
  // bar sizes could be extracted only on android
252
- const systemBars = await ((_9 = (_8 = this._spec).getSystemBars) === null || _9 === void 0 ? void 0 : _9.call(_8, this.target).catch(() => null));
254
+ const systemBars = await ((_12 = (_11 = this._spec).getSystemBars) === null || _12 === void 0 ? void 0 : _12.call(_11, this.target).catch(() => null));
253
255
  const { statusBar, navigationBar } = systemBars !== null && systemBars !== void 0 ? systemBars : {};
254
256
  if (statusBar === null || statusBar === void 0 ? void 0 : statusBar.visible) {
255
257
  this._logger.log('Driver status bar', statusBar);
256
258
  const statusBarSize = statusBar.height;
257
259
  // when status bar is overlapping content on android it returns status bar height equal to display height
258
260
  if (statusBarSize < this._driverInfo.displaySize.height) {
259
- this._driverInfo.statusBarSize = Math.max((_10 = this._driverInfo.statusBarSize) !== null && _10 !== void 0 ? _10 : 0, statusBarSize);
261
+ this._driverInfo.statusBarSize = Math.max((_13 = this._driverInfo.statusBarSize) !== null && _13 !== void 0 ? _13 : 0, statusBarSize);
260
262
  }
261
263
  }
262
264
  if (navigationBar === null || navigationBar === void 0 ? void 0 : navigationBar.visible) {
@@ -265,28 +267,28 @@ class Driver {
265
267
  if (navigationBar.x > 0)
266
268
  this._driverInfo.orientation = 'landscape-secondary';
267
269
  // navigation bar size could be its height or width depending on screen orientation
268
- const navigationBarSize = navigationBar[((_11 = this.orientation) === null || _11 === void 0 ? void 0 : _11.startsWith('landscape')) ? 'width' : 'height'];
270
+ const navigationBarSize = navigationBar[((_14 = this.orientation) === null || _14 === void 0 ? void 0 : _14.startsWith('landscape')) ? 'width' : 'height'];
269
271
  // when navigation bar is invisible on android it returns navigation bar size equal to display size
270
272
  if (navigationBarSize <
271
- this._driverInfo.displaySize[((_12 = this.orientation) === null || _12 === void 0 ? void 0 : _12.startsWith('landscape')) ? 'width' : 'height']) {
272
- this._driverInfo.navigationBarSize = Math.max((_13 = this._driverInfo.navigationBarSize) !== null && _13 !== void 0 ? _13 : 0, navigationBarSize);
273
+ this._driverInfo.displaySize[((_15 = this.orientation) === null || _15 === void 0 ? void 0 : _15.startsWith('landscape')) ? 'width' : 'height']) {
274
+ this._driverInfo.navigationBarSize = Math.max((_16 = this._driverInfo.navigationBarSize) !== null && _16 !== void 0 ? _16 : 0, navigationBarSize);
273
275
  }
274
276
  else {
275
277
  this._driverInfo.navigationBarSize = 0;
276
278
  }
277
279
  }
278
280
  // bar sizes have to be scaled on android
279
- (_31 = this._driverInfo).statusBarSize && (_31.statusBarSize = this._driverInfo.statusBarSize / this.pixelRatio);
280
- (_32 = this._driverInfo).navigationBarSize && (_32.navigationBarSize = this._driverInfo.navigationBarSize / this.pixelRatio);
281
+ (_35 = this._driverInfo).statusBarSize && (_35.statusBarSize = this._driverInfo.statusBarSize / this.pixelRatio);
282
+ (_36 = this._driverInfo).navigationBarSize && (_36.navigationBarSize = this._driverInfo.navigationBarSize / this.pixelRatio);
281
283
  windowSize = utils.geometry.scale(windowSize, 1 / this.pixelRatio);
282
- (_33 = this._driverInfo).displaySize && (_33.displaySize = utils.geometry.scale(this._driverInfo.displaySize, 1 / this.pixelRatio));
284
+ (_37 = this._driverInfo).displaySize && (_37.displaySize = utils.geometry.scale(this._driverInfo.displaySize, 1 / this.pixelRatio));
283
285
  }
284
286
  if (this.isIOS) {
285
- if ((_14 = this.orientation) === null || _14 === void 0 ? void 0 : _14.startsWith('landscape'))
287
+ if ((_17 = this.orientation) === null || _17 === void 0 ? void 0 : _17.startsWith('landscape'))
286
288
  this._driverInfo.statusBarSize = 0;
287
289
  }
288
290
  // calculate viewport location
289
- (_15 = (_34 = this._driverInfo).viewportLocation) !== null && _15 !== void 0 ? _15 : (_34.viewportLocation = {
291
+ (_18 = (_38 = this._driverInfo).viewportLocation) !== null && _18 !== void 0 ? _18 : (_38.viewportLocation = {
290
292
  x: this.orientation === 'landscape' ? this.navigationBarSize : 0,
291
293
  y: this.statusBarSize,
292
294
  });
@@ -295,7 +297,7 @@ class Driver {
295
297
  this._driverInfo.viewportSize = { ...this._driverInfo.displaySize };
296
298
  this._driverInfo.viewportSize.height -= this.statusBarSize;
297
299
  if (this.isAndroid) {
298
- this._driverInfo.viewportSize[((_16 = this.orientation) === null || _16 === void 0 ? void 0 : _16.startsWith('landscape')) ? 'width' : 'height'] -=
300
+ this._driverInfo.viewportSize[((_19 = this.orientation) === null || _19 === void 0 ? void 0 : _19.startsWith('landscape')) ? 'width' : 'height'] -=
299
301
  this.navigationBarSize;
300
302
  }
301
303
  }
@@ -318,12 +320,12 @@ class Driver {
318
320
  }
319
321
  // TODO: if user opts into NML, skip initializing the helpers
320
322
  // init helper lib
321
- if (!((_17 = this._customConfig) === null || _17 === void 0 ? void 0 : _17.disableHelper)) {
323
+ if (!((_20 = this._customConfig) === null || _20 === void 0 ? void 0 : _20.disableHelper)) {
322
324
  this._helper = this.isIOS
323
325
  ? await helper_ios_1.HelperIOS.make({ spec: this._spec, driver: this, logger: this._logger })
324
326
  : await helper_android_1.HelperAndroid.make({ spec: this._spec, driver: this, logger: this._logger });
325
327
  }
326
- this._logger.log(`Helper set to ${(_18 = this._helper) === null || _18 === void 0 ? void 0 : _18.name}`);
328
+ this._logger.log(`Helper set to ${(_21 = this._helper) === null || _21 === void 0 ? void 0 : _21.name}`);
327
329
  }
328
330
  this._logger.log('Combined driver info', this._driverInfo);
329
331
  return this;
@@ -411,7 +413,7 @@ class Driver {
411
413
  // end world
412
414
  async getSessionMetadata() {
413
415
  var _a;
414
- if (this.isExecutionGridClient)
416
+ if (this.isECClient)
415
417
  return await ((_a = this._spec) === null || _a === void 0 ? void 0 : _a.getSessionMetadata(this.target));
416
418
  }
417
419
  async refreshContexts() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@applitools/driver",
3
- "version": "1.11.25",
3
+ "version": "1.11.26",
4
4
  "description": "Applitools universal framework wrapper",
5
5
  "keywords": [
6
6
  "applitools",
@@ -87,13 +87,13 @@
87
87
  }
88
88
  },
89
89
  "dependencies": {
90
- "@applitools/logger": "1.1.40",
91
- "@applitools/snippets": "2.4.13",
92
- "@applitools/utils": "1.3.26",
90
+ "@applitools/logger": "1.1.42",
91
+ "@applitools/snippets": "2.4.14",
92
+ "@applitools/utils": "1.3.28",
93
93
  "semver": "7.3.7"
94
94
  },
95
95
  "devDependencies": {
96
- "@applitools/bongo": "^2.2.0",
96
+ "@applitools/bongo": "^2.2.2",
97
97
  "@applitools/scripts": "^1.2.0",
98
98
  "@types/mocha": "^9.1.1",
99
99
  "@types/node": "^17.0.31",
package/types/driver.d.ts CHANGED
@@ -60,9 +60,10 @@ export declare class Driver<TDriver, TContext, TElement, TSelector> {
60
60
  get isChromium(): boolean;
61
61
  get isIE(): boolean;
62
62
  get isEdgeLegacy(): boolean;
63
+ get isECClient(): boolean;
64
+ get isEC(): boolean;
63
65
  get sessionId(): string;
64
- get isExecutionGridClient(): boolean;
65
- get isExecutionGrid(): boolean;
66
+ get remoteHostname(): string | undefined;
66
67
  updateCurrentContext(context: Context<TDriver, TContext, TElement, TSelector>): void;
67
68
  init(): Promise<this>;
68
69
  switchWorld(options?: {
@@ -4,6 +4,7 @@ import type { ScreenOrientation, Cookie } from './types';
4
4
  import { type Selector } from './selector';
5
5
  export declare type DriverInfo = {
6
6
  sessionId?: string;
7
+ remoteHostname?: string;
7
8
  browserName?: string;
8
9
  browserVersion?: string;
9
10
  platformName?: string;
@@ -30,12 +31,12 @@ export declare type DriverInfo = {
30
31
  isMac?: boolean;
31
32
  isWindows?: boolean;
32
33
  isWebView?: boolean;
34
+ isECClient?: boolean;
33
35
  features?: {
34
36
  shadowSelector?: boolean;
35
37
  allCookies?: boolean;
36
38
  canExecuteOnlyFunctionScripts?: boolean;
37
39
  };
38
- isExecutionGridClient?: boolean;
39
40
  };
40
41
  export declare type WaitOptions = {
41
42
  state?: 'exist' | 'visible';