@applitools/driver 1.11.37 → 1.11.39

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/dist/element.js CHANGED
@@ -88,7 +88,8 @@ class Element {
88
88
  if (this.isRef)
89
89
  return false;
90
90
  element = element instanceof Element ? element.target : element;
91
- if (this.driver.isWeb) {
91
+ const environment = await this.driver.getEnvironment();
92
+ if (environment.isWeb) {
92
93
  return this._spec
93
94
  .executeScript(this.context.target, snippets.isEqualElements, [this.target, element])
94
95
  .catch(() => false);
@@ -102,7 +103,8 @@ class Element {
102
103
  var _a, _b;
103
104
  var _c;
104
105
  innerElement = innerElement instanceof Element ? innerElement.target : innerElement;
105
- if (this.driver.isWeb) {
106
+ const environment = await this.driver.getEnvironment();
107
+ if (environment.isWeb) {
106
108
  this._logger.log('Checking if web element with selector', this.selector, 'contains element', innerElement);
107
109
  return false; // TODO implement a snipped for web
108
110
  }
@@ -140,7 +142,8 @@ class Element {
140
142
  }
141
143
  async getRegion() {
142
144
  const region = await this.withRefresh(async () => {
143
- if (this.driver.isWeb) {
145
+ const environment = await this.driver.getEnvironment();
146
+ if (environment.isWeb) {
144
147
  this._logger.log('Extracting region of web element with selector', this.selector);
145
148
  return this.context.execute(snippets.getElementRect, [this, false]);
146
149
  }
@@ -161,7 +164,8 @@ class Element {
161
164
  }
162
165
  async getClientRegion() {
163
166
  const region = await this.withRefresh(async () => {
164
- if (this.driver.isWeb) {
167
+ const environment = await this.driver.getEnvironment();
168
+ if (environment.isWeb) {
165
169
  this._logger.log('Extracting region of web element with selector', this.selector);
166
170
  return this.context.execute(snippets.getElementRect, [this, true]);
167
171
  }
@@ -174,13 +178,14 @@ class Element {
174
178
  }
175
179
  async getContentRegion(options = {}) {
176
180
  var _a, _b;
177
- if (!this.driver.isNative)
181
+ const environment = await this.driver.getEnvironment();
182
+ if (!environment.isNative)
178
183
  return null;
179
184
  this._logger.log('Extracting content region of native element with selector', this.selector);
180
185
  const helper = await this.driver.getHelper();
181
186
  let contentRegion = await (helper === null || helper === void 0 ? void 0 : helper.getContentRegion(this, options));
182
187
  this._logger.log('Extracted content region using helper library', contentRegion);
183
- if (!contentRegion || !this.driver.isAndroid) {
188
+ if (!contentRegion || !environment.isAndroid) {
184
189
  let attrContentRegion = null;
185
190
  try {
186
191
  const size = JSON.parse(await this.getAttribute('contentSize'));
@@ -188,7 +193,7 @@ class Element {
188
193
  x: size.left,
189
194
  y: size.top,
190
195
  width: size.width,
191
- height: this.driver.isIOS
196
+ height: environment.isIOS
192
197
  ? Math.max(size.height, size.scrollableOffset)
193
198
  : size.height + size.scrollableOffset,
194
199
  };
@@ -198,7 +203,7 @@ class Element {
198
203
  }
199
204
  this._logger.log('Extracted content region using attribute', attrContentRegion);
200
205
  // ios workaround
201
- if (!attrContentRegion && this.driver.isIOS) {
206
+ if (!attrContentRegion && environment.isIOS) {
202
207
  try {
203
208
  const type = await this.getAttribute('type');
204
209
  if (type === 'XCUIElementTypeScrollView') {
@@ -236,7 +241,8 @@ class Element {
236
241
  if (this._state.contentSize)
237
242
  return this._state.contentSize;
238
243
  const size = await this.withRefresh(async () => {
239
- if (this.driver.isWeb) {
244
+ const environment = await this.driver.getEnvironment();
245
+ if (environment.isWeb) {
240
246
  this._logger.log('Extracting content size of web element with selector', this.selector);
241
247
  return this.context.execute(snippets.getElementContentSize, [this]);
242
248
  }
@@ -245,11 +251,12 @@ class Element {
245
251
  try {
246
252
  const contentRegion = await this.getContentRegion(options);
247
253
  this._state.contentSize = utils.geometry.size(contentRegion);
248
- if (this.driver.isAndroid) {
249
- this._state.contentSize = utils.geometry.scale(this._state.contentSize, 1 / this.driver.pixelRatio);
254
+ const viewport = await this.driver.getViewport();
255
+ if (environment.isAndroid) {
256
+ this._state.contentSize = utils.geometry.scale(this._state.contentSize, 1 / viewport.pixelRatio);
250
257
  }
251
- if (contentRegion.y < this.driver.statusBarSize) {
252
- this._state.contentSize.height -= this.driver.statusBarSize - contentRegion.y;
258
+ if (contentRegion.y < viewport.statusBarSize) {
259
+ this._state.contentSize.height -= viewport.statusBarSize - contentRegion.y;
253
260
  }
254
261
  return this._state.contentSize;
255
262
  }
@@ -266,7 +273,8 @@ class Element {
266
273
  async isPager() {
267
274
  this._logger.log('Check if element with selector', this.selector, 'is scrollable by pages');
268
275
  const isPager = await this.withRefresh(async () => {
269
- if (this.driver.isAndroid) {
276
+ const environment = await this.driver.getEnvironment();
277
+ if (environment.isAndroid) {
270
278
  const className = await this.getAttribute('className');
271
279
  return ['androidx.viewpager.widget.ViewPager'].includes(className);
272
280
  }
@@ -280,14 +288,15 @@ class Element {
280
288
  async isScrollable() {
281
289
  this._logger.log('Check if element with selector', this.selector, 'is scrollable');
282
290
  const isScrollable = await this.withRefresh(async () => {
283
- if (this.driver.isWeb) {
291
+ const environment = await this.driver.getEnvironment();
292
+ if (environment.isWeb) {
284
293
  return this.context.execute(snippets.isElementScrollable, [this]);
285
294
  }
286
- else if (this.driver.isAndroid) {
295
+ else if (environment.isAndroid) {
287
296
  const data = JSON.parse(await this.getAttribute('scrollable'));
288
297
  return Boolean(data) || false;
289
298
  }
290
- else if (this.driver.isIOS) {
299
+ else if (environment.isIOS) {
291
300
  const type = await this.getAttribute('type');
292
301
  return ['XCUIElementTypeScrollView', 'XCUIElementTypeTable', 'XCUIElementTypeCollectionView'].includes(type);
293
302
  }
@@ -298,7 +307,8 @@ class Element {
298
307
  async isRoot() {
299
308
  // TODO replace with snippet
300
309
  return this.withRefresh(async () => {
301
- if (this.driver.isWeb) {
310
+ const environment = await this.driver.getEnvironment();
311
+ if (environment.isWeb) {
302
312
  const rootElement = await this.context.element({ type: 'css', selector: 'html' });
303
313
  return this.equals(rootElement);
304
314
  }
@@ -308,7 +318,8 @@ class Element {
308
318
  });
309
319
  }
310
320
  async getShadowRoot() {
311
- if (!this.driver.isWeb)
321
+ const environment = await this.driver.getEnvironment();
322
+ if (!environment.isWeb)
312
323
  return null;
313
324
  return this._spec.executeScript(this.context.target, snippets.getShadowRoot, [this.target]);
314
325
  }
@@ -316,11 +327,12 @@ class Element {
316
327
  var _a;
317
328
  var _b;
318
329
  if (this._state.touchPadding == null) {
319
- if (this.driver.isWeb)
330
+ const environment = await this.driver.getEnvironment();
331
+ if (environment.isWeb)
320
332
  this._state.touchPadding = 0;
321
- else if (this.driver.isIOS)
333
+ else if (environment.isIOS)
322
334
  this._state.touchPadding = 10;
323
- else if (this.driver.isAndroid) {
335
+ else if (environment.isAndroid) {
324
336
  const helper = await this.driver.getHelper();
325
337
  if ((helper === null || helper === void 0 ? void 0 : helper.name) === 'android') {
326
338
  this._state.touchPadding = await helper.getTouchPadding();
@@ -342,7 +354,8 @@ class Element {
342
354
  }
343
355
  async getText() {
344
356
  const text = await this.withRefresh(async () => {
345
- if (this.driver.isWeb) {
357
+ const environment = await this.driver.getEnvironment();
358
+ if (environment.isWeb) {
346
359
  return '';
347
360
  }
348
361
  else {
@@ -364,7 +377,8 @@ class Element {
364
377
  const value = await this.withRefresh(async () => {
365
378
  var _a;
366
379
  var _b;
367
- if (this.driver.isWeb) {
380
+ const environment = await this.driver.getEnvironment();
381
+ if (environment.isWeb) {
368
382
  const properties = await this.context.execute(snippets.getElementProperties, [this, [name]]);
369
383
  return properties[name];
370
384
  }
@@ -380,7 +394,7 @@ class Element {
380
394
  throw err;
381
395
  }
382
396
  finally {
383
- if (this.driver.isAndroid && name === 'contentSize') {
397
+ if (environment.isAndroid && name === 'contentSize') {
384
398
  // android has a bug when after extracting 'contentSize' attribute the element is being scrolled by undetermined number of pixels
385
399
  this._logger.log('Stabilizing android scroll offset');
386
400
  const originalScrollOffset = await this.getScrollOffset();
@@ -394,7 +408,8 @@ class Element {
394
408
  return value;
395
409
  }
396
410
  async setAttribute(name, value) {
397
- if (this.driver.isWeb) {
411
+ const environment = await this.driver.getEnvironment();
412
+ if (environment.isWeb) {
398
413
  await this.context.execute(snippets.setElementAttributes, [this, { [name]: value }]);
399
414
  }
400
415
  }
@@ -402,10 +417,11 @@ class Element {
402
417
  return this.withRefresh(async () => {
403
418
  this._logger.log(`Scrolling to offset (${offset.x}, ${offset.y}) element with selector`, this.selector);
404
419
  offset = utils.geometry.round({ x: Math.max(offset.x, 0), y: Math.max(offset.y, 0) });
405
- if (this.driver.isWeb) {
420
+ const environment = await this.driver.getEnvironment();
421
+ if (environment.isWeb) {
406
422
  let actualOffset = await this.context.execute(snippets.scrollTo, [this, offset]);
407
423
  // iOS has an issue when scroll offset is read immediately after it is been set it will always return the exact value that was set
408
- if (this.driver.isIOS)
424
+ if (environment.isIOS)
409
425
  actualOffset = await this.getScrollOffset();
410
426
  return actualOffset;
411
427
  }
@@ -413,7 +429,7 @@ class Element {
413
429
  const currentScrollOffset = await this.getScrollOffset();
414
430
  if (!(options === null || options === void 0 ? void 0 : options.force) && utils.geometry.equals(offset, currentScrollOffset))
415
431
  return currentScrollOffset;
416
- if (utils.geometry.equals(offset, { x: 0, y: 0 }) && this.driver.isAndroid) {
432
+ if (utils.geometry.equals(offset, { x: 0, y: 0 }) && environment.isAndroid) {
417
433
  const helper = await this.driver.getHelper();
418
434
  if ((helper === null || helper === void 0 ? void 0 : helper.name) === 'android') {
419
435
  await helper.scrollToTop(this);
@@ -432,9 +448,10 @@ class Element {
432
448
  let remainingOffset = utils.geometry.equals(requiredOffset, { x: 0, y: 0 })
433
449
  ? { x: -maxOffset.x, y: -maxOffset.y } // if it has to be scrolled to the very beginning, then scroll maximum amount of pixels
434
450
  : utils.geometry.offsetNegative(requiredOffset, currentScrollOffset);
435
- if (this.driver.isAndroid) {
436
- remainingOffset = utils.geometry.round(utils.geometry.scale(remainingOffset, this.driver.pixelRatio));
437
- effectiveRegion = utils.geometry.round(utils.geometry.scale(effectiveRegion, this.driver.pixelRatio));
451
+ if (environment.isAndroid) {
452
+ const viewport = await this.driver.getViewport();
453
+ remainingOffset = utils.geometry.round(utils.geometry.scale(remainingOffset, viewport.pixelRatio));
454
+ effectiveRegion = utils.geometry.round(utils.geometry.scale(effectiveRegion, viewport.pixelRatio));
438
455
  }
439
456
  const isPager = await this.isPager();
440
457
  const touchPadding = await this.getTouchPadding();
@@ -463,7 +480,7 @@ class Element {
463
480
  { action: 'release' },
464
481
  ]);
465
482
  }
466
- else if (this.driver.isAndroid) {
483
+ else if (environment.isAndroid) {
467
484
  actions.push([
468
485
  // move through scrolling gap (actual scrolling will be triggered only after that)
469
486
  { action: 'press', y: yTrack, x: xStart - xGap },
@@ -477,7 +494,7 @@ class Element {
477
494
  { action: 'release' },
478
495
  ]);
479
496
  }
480
- else if (this.driver.isIOS) {
497
+ else if (environment.isIOS) {
481
498
  actions.push([
482
499
  // move through scrolling gap (actual scrolling will be triggered only after that)
483
500
  { action: 'press', y: yTrack, x: xStart - xGap },
@@ -518,7 +535,7 @@ class Element {
518
535
  { action: 'release' },
519
536
  ]);
520
537
  }
521
- else if (this.driver.isAndroid) {
538
+ else if (environment.isAndroid) {
522
539
  actions.push([
523
540
  // move through scrolling gap (actual scrolling will be triggered only after that)
524
541
  { action: 'press', x: xTrack, y: yStart - yGap },
@@ -532,7 +549,7 @@ class Element {
532
549
  { action: 'release' },
533
550
  ]);
534
551
  }
535
- else if (this.driver.isIOS) {
552
+ else if (environment.isIOS) {
536
553
  actions.push([
537
554
  // move through scrolling gap (actual scrolling will be triggered only after that)
538
555
  { action: 'press', x: xTrack, y: yStart - yGap },
@@ -551,7 +568,7 @@ class Element {
551
568
  }
552
569
  // ios actions should be executed one-by-one sequentially, otherwise the result isn't stable
553
570
  // pages should be scrolled one-by-one as well
554
- if (isPager || this.driver.isIOS) {
571
+ if (isPager || environment.isIOS) {
555
572
  for (const action of actions) {
556
573
  await this._spec.performAction(this.driver.target, action);
557
574
  }
@@ -570,7 +587,8 @@ class Element {
570
587
  }
571
588
  async translateTo(offset) {
572
589
  offset = { x: Math.round(offset.x), y: Math.round(offset.y) };
573
- if (this.driver.isWeb) {
590
+ const environment = await this.driver.getEnvironment();
591
+ if (environment.isWeb) {
574
592
  return this.withRefresh(async () => this.context.execute(snippets.translateTo, [this, offset]));
575
593
  }
576
594
  else {
@@ -579,7 +597,8 @@ class Element {
579
597
  }
580
598
  async getScrollOffset() {
581
599
  var _a;
582
- if (this.driver.isWeb) {
600
+ const environment = await this.driver.getEnvironment();
601
+ if (environment.isWeb) {
583
602
  return this.withRefresh(() => this.context.execute(snippets.getElementScrollOffset, [this]));
584
603
  }
585
604
  else {
@@ -587,7 +606,8 @@ class Element {
587
606
  }
588
607
  }
589
608
  async getTranslateOffset() {
590
- if (this.driver.isWeb) {
609
+ const environment = await this.driver.getEnvironment();
610
+ if (environment.isWeb) {
591
611
  return this.withRefresh(() => this.context.execute(snippets.getElementTranslateOffset, [this]));
592
612
  }
593
613
  else {
@@ -595,7 +615,8 @@ class Element {
595
615
  }
596
616
  }
597
617
  async getInnerOffset() {
598
- if (this.driver.isWeb) {
618
+ const environment = await this.driver.getEnvironment();
619
+ if (environment.isWeb) {
599
620
  return this.withRefresh(() => this.context.execute(snippets.getElementInnerOffset, [this]));
600
621
  }
601
622
  else {
@@ -614,7 +635,8 @@ class Element {
614
635
  }
615
636
  async preserveState() {
616
637
  const scrollOffset = await this.getScrollOffset();
617
- const transforms = this.driver.isWeb
638
+ const environment = await this.driver.getEnvironment();
639
+ const transforms = environment.isWeb
618
640
  ? await this.context.execute(snippets.getElementStyleProperties, [this, ['transform', '-webkit-transform']])
619
641
  : null;
620
642
  if (!utils.types.has(this._state, ['scrollOffset', 'transforms'])) {
@@ -634,7 +656,8 @@ class Element {
634
656
  }
635
657
  }
636
658
  async hideScrollbars() {
637
- if (this.driver.isNative)
659
+ const environment = await this.driver.getEnvironment();
660
+ if (environment.isNative)
638
661
  return;
639
662
  if (this._originalOverflow)
640
663
  return;
@@ -644,7 +667,8 @@ class Element {
644
667
  });
645
668
  }
646
669
  async restoreScrollbars() {
647
- if (this.driver.isNative)
670
+ const environment = await this.driver.getEnvironment();
671
+ if (environment.isNative)
648
672
  return;
649
673
  if (!this._originalOverflow)
650
674
  return;
@@ -120,17 +120,14 @@ class MockDriver {
120
120
  this.mockScript(snippets.getShadowRoot, ([element]) => {
121
121
  return element;
122
122
  });
123
- this.mockScript(snippets.getBrowserInfo, () => {
123
+ this.mockScript(snippets.getUserAgent, () => {
124
124
  return JSON.stringify({
125
125
  status: 'SUCCESS',
126
- value: {
127
- userAgent: this._ua !== undefined ? this._ua : this.info.isMobile ? DEFAULT_MOBILE_UA : DEFAULT_DESKTOP_UA,
128
- pixelRatio: 1,
129
- },
126
+ value: this._ua !== undefined ? this._ua : this.environment.isMobile ? DEFAULT_MOBILE_UA : DEFAULT_DESKTOP_UA,
130
127
  });
131
128
  });
132
- this.mockScript(snippets.getViewportSize, () => {
133
- return { width: this._window.rect.width, height: this._window.rect.height };
129
+ this.mockScript(snippets.getViewport, () => {
130
+ return { viewportSize: { width: this._window.rect.width, height: this._window.rect.height }, pixelRation: 1 };
134
131
  });
135
132
  this.mockScript(snippets.getElementXpath, ([element]) => {
136
133
  if (element.xpath)
@@ -254,7 +251,7 @@ class MockDriver {
254
251
  return;
255
252
  this[name] = method;
256
253
  }
257
- get info() {
254
+ get environment() {
258
255
  return {
259
256
  isMobile: this._device ? Boolean(this._device.isMobile) : false,
260
257
  isNative: this._device ? Boolean(this._device.isNative) : false,
@@ -266,7 +263,7 @@ class MockDriver {
266
263
  };
267
264
  }
268
265
  async executeScript(script, args = []) {
269
- if (this.info.isNative)
266
+ if (this.environment.isNative)
270
267
  throw new Error("Native context doesn't support this method");
271
268
  let result = this._scripts.get(String(script));
272
269
  if (!result) {
@@ -327,17 +324,17 @@ class MockDriver {
327
324
  Object.assign(this._window.rect, rect);
328
325
  }
329
326
  async getUrl() {
330
- if (this.info.isNative)
327
+ if (this.environment.isNative)
331
328
  throw new Error("Native context doesn't support this method");
332
329
  return this._window.url;
333
330
  }
334
331
  async getTitle() {
335
- if (this.info.isNative)
332
+ if (this.environment.isNative)
336
333
  throw new Error("Native context doesn't support this method");
337
334
  return this._window.title;
338
335
  }
339
336
  async visit(url) {
340
- if (this.info.isNative)
337
+ if (this.environment.isNative)
341
338
  throw new Error("Native context doesn't support this method");
342
339
  this._window.url = url;
343
340
  }
@@ -106,7 +106,7 @@ async function takeScreenshot(driver) {
106
106
  }
107
107
  exports.takeScreenshot = takeScreenshot;
108
108
  async function getDriverInfo(driver) {
109
- return driver.info;
109
+ return { environment: driver.environment };
110
110
  }
111
111
  exports.getDriverInfo = getDriverInfo;
112
112
  async function getWindowSize(driver) {
@@ -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.parseBrowser = exports.parsePlatform = exports.parseUserAgent = void 0;
26
+ exports.extractUserAgentEnvironment = void 0;
27
27
  const utils = __importStar(require("@applitools/utils"));
28
28
  const MAJOR_MINOR = '(\\d+)(?:[_.](\\d+))?';
29
29
  const PLATFORM_REGEXES = [
@@ -52,16 +52,37 @@ const BROWSER_REGEXPES = [
52
52
  ];
53
53
  const HIDDEN_IE_REGEX = new RegExp(`(?:rv:${MAJOR_MINOR}\\) like Gecko)`);
54
54
  const BROWSER_VERSION_REGEX = new RegExp(`(?:Version/${MAJOR_MINOR})`);
55
- function parseUserAgent(userAgent) {
56
- utils.guard.notNull(userAgent, { name: 'userAgent' });
57
- userAgent = userAgent.trim();
58
- return {
59
- ...parsePlatform(userAgent),
60
- ...parseBrowser(userAgent),
55
+ const WINDOWS_VERSIONS = {
56
+ '0.1.0': '7',
57
+ '0.2.0': '8',
58
+ '0.3.0': '8.1',
59
+ '10.0.0': '10',
60
+ '15.0.0': '11',
61
+ };
62
+ function extractUserAgentEnvironment(userAgent) {
63
+ var _a, _b, _c, _d;
64
+ let userAgentLegacy, userAgentObject;
65
+ if (utils.types.isString(userAgent)) {
66
+ userAgentLegacy = userAgent.trim();
67
+ }
68
+ else {
69
+ userAgentLegacy = userAgent.legacy.trim();
70
+ userAgentObject = userAgent;
71
+ }
72
+ const userAgentLegacyEnvironment = {
73
+ ...extractUserAgentLegacyPlatform(userAgentLegacy),
74
+ ...extractUserAgentLegacyBrowser(userAgentLegacy),
61
75
  };
76
+ const userAgentEnvironment = userAgentObject && extractUserAgentObjectEnvironment(userAgentObject);
77
+ const environment = { ...userAgentEnvironment };
78
+ (_a = environment.platformName) !== null && _a !== void 0 ? _a : (environment.platformName = userAgentLegacyEnvironment.platformName);
79
+ (_b = environment.platformVersion) !== null && _b !== void 0 ? _b : (environment.platformVersion = userAgentLegacyEnvironment.platformVersion);
80
+ environment.browserName = (_c = userAgentLegacyEnvironment.browserName) !== null && _c !== void 0 ? _c : environment.browserName;
81
+ environment.browserVersion = (_d = userAgentLegacyEnvironment.browserVersion) !== null && _d !== void 0 ? _d : environment.browserVersion;
82
+ return environment;
62
83
  }
63
- exports.parseUserAgent = parseUserAgent;
64
- function parsePlatform(userAgent) {
84
+ exports.extractUserAgentEnvironment = extractUserAgentEnvironment;
85
+ function extractUserAgentLegacyPlatform(userAgent) {
65
86
  const platformRegExp = PLATFORM_REGEXES.find(regexp => regexp.test(userAgent));
66
87
  if (!platformRegExp)
67
88
  return { platformName: 'Unknown' };
@@ -95,8 +116,7 @@ function parsePlatform(userAgent) {
95
116
  return { platformName, platformVersion: platformMajorVersion };
96
117
  }
97
118
  }
98
- exports.parsePlatform = parsePlatform;
99
- function parseBrowser(userAgent) {
119
+ function extractUserAgentLegacyBrowser(userAgent) {
100
120
  const browserRegExp = BROWSER_REGEXPES.find(regexp => regexp.test(userAgent));
101
121
  if (!browserRegExp) {
102
122
  if (HIDDEN_IE_REGEX.test(userAgent)) {
@@ -117,4 +137,25 @@ function parseBrowser(userAgent) {
117
137
  }
118
138
  return result;
119
139
  }
120
- exports.parseBrowser = parseBrowser;
140
+ function extractUserAgentObjectEnvironment(userAgent) {
141
+ var _a, _b, _c, _d;
142
+ const chromiumBrand = (_a = userAgent.brands) === null || _a === void 0 ? void 0 : _a.find(brand => /Chromium/i.test(brand.brand));
143
+ 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;
144
+ const environment = {
145
+ browserName: browserBrand === null || browserBrand === void 0 ? void 0 : browserBrand.brand,
146
+ browserVersion: browserBrand === null || browserBrand === void 0 ? void 0 : browserBrand.version,
147
+ platformName: userAgent.platform || undefined,
148
+ platformVersion: userAgent.platformVersion || undefined,
149
+ deviceName: userAgent.model || undefined,
150
+ isMobile: userAgent.mobile,
151
+ isChromium: Boolean(chromiumBrand),
152
+ };
153
+ if (environment.platformName === 'Windows') {
154
+ environment.platformVersion = WINDOWS_VERSIONS[environment.platformVersion];
155
+ }
156
+ else if (environment.platformName === 'macOS') {
157
+ environment.platformName = 'Mac OS X';
158
+ environment.platformVersion = (_d = environment.platformVersion) === null || _d === void 0 ? void 0 : _d.split(/[._]/, 2).join('.');
159
+ }
160
+ return environment;
161
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@applitools/driver",
3
- "version": "1.11.37",
3
+ "version": "1.11.39",
4
4
  "description": "Applitools universal framework wrapper",
5
5
  "keywords": [
6
6
  "applitools",
@@ -82,12 +82,12 @@
82
82
  },
83
83
  "dependencies": {
84
84
  "@applitools/logger": "1.1.48",
85
- "@applitools/snippets": "2.4.17",
85
+ "@applitools/snippets": "2.4.19",
86
86
  "@applitools/utils": "1.3.32",
87
87
  "semver": "7.3.7"
88
88
  },
89
89
  "devDependencies": {
90
- "@applitools/bongo": "^3.0.1",
90
+ "@applitools/bongo": "^3.0.3",
91
91
  "@types/node": "^12.20.55"
92
92
  },
93
93
  "engines": {
@@ -1,4 +1,3 @@
1
- import { type DriverInfo } from './spec-driver';
2
- type Capabilities = Record<string, any>;
3
- export declare function parseCapabilities(capabilities: Capabilities): DriverInfo;
4
- export {};
1
+ import type { Capabilities, Environment, Viewport } from './types';
2
+ export declare function extractCapabilitiesEnvironment(capabilities: Capabilities): Partial<Environment>;
3
+ export declare function extractCapabilitiesViewport(capabilities: Capabilities): Partial<Viewport>;