@applitools/driver 1.9.0 → 1.9.3
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/driver.js +19 -13
- package/dist/element.js +31 -17
- package/package.json +9 -6
- package/types/element.d.ts +1 -1
package/dist/driver.js
CHANGED
|
@@ -175,13 +175,14 @@ class Driver {
|
|
|
175
175
|
// this value always excludes the height of the navigation bar, and sometimes it also excludes the height of the status bar
|
|
176
176
|
let windowSize = await this._spec.getWindowSize(this.target);
|
|
177
177
|
(_r = (_4 = this._driverInfo).displaySize) !== null && _r !== void 0 ? _r : (_4.displaySize = windowSize);
|
|
178
|
+
const orientation = await this.getOrientation();
|
|
178
179
|
if (this.isAndroid) {
|
|
179
180
|
// bar sizes could be extracted only on android
|
|
180
181
|
const barsSize = await ((_t = (_s = this._spec).getBarsSize) === null || _t === void 0 ? void 0 : _t.call(_s, this.target).catch(() => undefined));
|
|
181
182
|
if (barsSize) {
|
|
182
183
|
this._logger.log('Driver bars size', barsSize);
|
|
183
184
|
// navigation bar height is replaced with the width in landscape orientation on android (due to the bug in appium)
|
|
184
|
-
if (
|
|
185
|
+
if (orientation === 'landscape')
|
|
185
186
|
barsSize.navigationBarHeight = barsSize.navigationBarWidth;
|
|
186
187
|
// when status bar is overlapping content on android it returns status bar height equal to viewport height
|
|
187
188
|
if (barsSize.statusBarHeight < this._driverInfo.displaySize.height) {
|
|
@@ -201,10 +202,18 @@ class Driver {
|
|
|
201
202
|
// calculate viewport size
|
|
202
203
|
if (!this._driverInfo.viewportSize) {
|
|
203
204
|
if (this.navigationBarHeight > 1) {
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
205
|
+
if (orientation === 'landscape') {
|
|
206
|
+
this._driverInfo.viewportSize = {
|
|
207
|
+
width: this._driverInfo.displaySize.height - this.navigationBarHeight,
|
|
208
|
+
height: this._driverInfo.displaySize.width - this.statusBarHeight,
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
else {
|
|
212
|
+
this._driverInfo.viewportSize = {
|
|
213
|
+
width: this._driverInfo.displaySize.width,
|
|
214
|
+
height: this._driverInfo.displaySize.height - this.statusBarHeight - this.navigationBarHeight,
|
|
215
|
+
};
|
|
216
|
+
}
|
|
208
217
|
}
|
|
209
218
|
else {
|
|
210
219
|
this._driverInfo.viewportSize = {
|
|
@@ -454,12 +463,6 @@ class Driver {
|
|
|
454
463
|
else {
|
|
455
464
|
this._logger.log('Extracting viewport size from native driver');
|
|
456
465
|
size = await this.getDisplaySize();
|
|
457
|
-
if (size.height > size.width) {
|
|
458
|
-
const orientation = await this.getOrientation();
|
|
459
|
-
if (orientation === 'landscape') {
|
|
460
|
-
size = { width: size.height, height: size.width };
|
|
461
|
-
}
|
|
462
|
-
}
|
|
463
466
|
size.height -= this.statusBarHeight;
|
|
464
467
|
}
|
|
465
468
|
this._logger.log(`Rounding viewport size using`, this._customConfig.useCeilForViewportSize ? 'ceil' : 'round');
|
|
@@ -520,11 +523,14 @@ class Driver {
|
|
|
520
523
|
var _a;
|
|
521
524
|
if (this.isWeb && !this.isMobile)
|
|
522
525
|
return;
|
|
523
|
-
if ((_a = this._driverInfo) === null || _a === void 0 ? void 0 : _a.
|
|
526
|
+
if ((_a = this._driverInfo) === null || _a === void 0 ? void 0 : _a.displaySize) {
|
|
524
527
|
this._logger.log('Extracting display size from native driver using cached value');
|
|
525
528
|
return this._driverInfo.displaySize;
|
|
526
529
|
}
|
|
527
|
-
|
|
530
|
+
let size = await this._spec.getWindowSize(this.target);
|
|
531
|
+
if ((await this.getOrientation()) === 'landscape' && size.height > size.width) {
|
|
532
|
+
size = { width: size.height, height: size.width };
|
|
533
|
+
}
|
|
528
534
|
const normalizedSize = this.isAndroid ? utils.geometry.scale(size, 1 / this.pixelRatio) : size;
|
|
529
535
|
this._logger.log('Extracted and normalized display size:', normalizedSize);
|
|
530
536
|
return normalizedSize;
|
package/dist/element.js
CHANGED
|
@@ -110,7 +110,9 @@ class Element {
|
|
|
110
110
|
x: contentSize.left,
|
|
111
111
|
y: contentSize.top,
|
|
112
112
|
width: contentSize.width,
|
|
113
|
-
height:
|
|
113
|
+
height: this.driver.isIOS
|
|
114
|
+
? Math.max(contentSize.height, contentSize.scrollableOffset)
|
|
115
|
+
: contentSize.height + contentSize.scrollableOffset,
|
|
114
116
|
};
|
|
115
117
|
})
|
|
116
118
|
.catch(() => this._spec.getElementRegion(this.driver.target, this.target));
|
|
@@ -197,7 +199,9 @@ class Element {
|
|
|
197
199
|
x: contentSize.left,
|
|
198
200
|
y: contentSize.top,
|
|
199
201
|
width: contentSize.width,
|
|
200
|
-
height:
|
|
202
|
+
height: this.driver.isIOS
|
|
203
|
+
? Math.max(contentSize.height, contentSize.scrollableOffset)
|
|
204
|
+
: contentSize.height + contentSize.scrollableOffset,
|
|
201
205
|
};
|
|
202
206
|
})
|
|
203
207
|
.catch(err => {
|
|
@@ -281,11 +285,11 @@ class Element {
|
|
|
281
285
|
this._state.touchPadding = 10;
|
|
282
286
|
else if (this.driver.isAndroid) {
|
|
283
287
|
const touchPadding = await this.getAttribute('contentSize')
|
|
284
|
-
.then(
|
|
288
|
+
.then(data => JSON.parse(data).touchPadding)
|
|
285
289
|
.catch(err => {
|
|
286
290
|
this._logger.warn(`Unable to get the attribute 'contentSize' when looking up 'touchPadding' due to the following error: '${err.message}'`);
|
|
287
291
|
});
|
|
288
|
-
this._state.touchPadding = touchPadding !== null && touchPadding !== void 0 ? touchPadding :
|
|
292
|
+
this._state.touchPadding = touchPadding !== null && touchPadding !== void 0 ? touchPadding : 21;
|
|
289
293
|
this._logger.log('Touch padding set:', this._state.touchPadding);
|
|
290
294
|
}
|
|
291
295
|
}
|
|
@@ -307,8 +311,11 @@ class Element {
|
|
|
307
311
|
async getAttribute(name) {
|
|
308
312
|
var _a;
|
|
309
313
|
// we assumes that attributes are not changed during the session
|
|
310
|
-
if ((_a = this._state.attributes) === null || _a === void 0 ? void 0 : _a[name])
|
|
314
|
+
if ((_a = this._state.attributes) === null || _a === void 0 ? void 0 : _a[name]) {
|
|
315
|
+
if (this._state.attributes[name] instanceof Error)
|
|
316
|
+
throw this._state.attributes[name];
|
|
311
317
|
return this._state.attributes[name];
|
|
318
|
+
}
|
|
312
319
|
const value = await this.withRefresh(async () => {
|
|
313
320
|
var _a;
|
|
314
321
|
var _b;
|
|
@@ -318,17 +325,24 @@ class Element {
|
|
|
318
325
|
}
|
|
319
326
|
else {
|
|
320
327
|
this._logger.log(`Extracting "${name}" attribute of native element with selector`, this.selector);
|
|
321
|
-
const value = await this._spec.getElementAttribute(this.driver.target, this.target, name);
|
|
322
328
|
(_a = (_b = this._state).attributes) !== null && _a !== void 0 ? _a : (_b.attributes = {});
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
329
|
+
try {
|
|
330
|
+
this._state.attributes[name] = await this._spec.getElementAttribute(this.driver.target, this.target, name);
|
|
331
|
+
return this._state.attributes[name];
|
|
332
|
+
}
|
|
333
|
+
catch (err) {
|
|
334
|
+
this._state.attributes[name] = err;
|
|
335
|
+
throw err;
|
|
336
|
+
}
|
|
337
|
+
finally {
|
|
338
|
+
if (this.driver.isAndroid && name === 'contentSize') {
|
|
339
|
+
// android has a bug when after extracting 'contentSize' attribute the element is being scrolled by undetermined number of pixels
|
|
340
|
+
this._logger.log('Stabilizing android scroll offset');
|
|
341
|
+
const originalScrollOffset = await this.getScrollOffset();
|
|
342
|
+
await this.scrollTo({ x: 0, y: 0 }, { force: true });
|
|
343
|
+
await this.scrollTo(originalScrollOffset);
|
|
344
|
+
}
|
|
330
345
|
}
|
|
331
|
-
return value;
|
|
332
346
|
}
|
|
333
347
|
});
|
|
334
348
|
this._logger.log(`Extracted element "${name}" attribute:`, value);
|
|
@@ -366,7 +380,7 @@ class Element {
|
|
|
366
380
|
: utils.geometry.offsetNegative(requiredOffset, currentScrollOffset);
|
|
367
381
|
if (this.driver.isAndroid) {
|
|
368
382
|
remainingOffset = utils.geometry.scale(remainingOffset, this.driver.pixelRatio);
|
|
369
|
-
effectiveRegion = utils.geometry.scale(
|
|
383
|
+
effectiveRegion = utils.geometry.scale(effectiveRegion, this.driver.pixelRatio);
|
|
370
384
|
}
|
|
371
385
|
const actions = [];
|
|
372
386
|
const touchPadding = await this.getTouchPadding();
|
|
@@ -460,10 +474,10 @@ class Element {
|
|
|
460
474
|
await this._spec.performAction(this.driver.target, [].concat(...actions));
|
|
461
475
|
}
|
|
462
476
|
const actualScrollableRegion = await this.getClientRegion();
|
|
463
|
-
this._state.scrollOffset = utils.geometry.offsetNegative(requiredOffset, {
|
|
477
|
+
this._state.scrollOffset = utils.geometry.round(utils.geometry.offsetNegative(requiredOffset, {
|
|
464
478
|
x: scrollableRegion.x - actualScrollableRegion.x,
|
|
465
479
|
y: scrollableRegion.y - actualScrollableRegion.y,
|
|
466
|
-
});
|
|
480
|
+
}));
|
|
467
481
|
return this._state.scrollOffset;
|
|
468
482
|
}
|
|
469
483
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@applitools/driver",
|
|
3
|
-
"version": "1.9.
|
|
3
|
+
"version": "1.9.3",
|
|
4
4
|
"description": "Applitools universal framework wrapper",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"applitools",
|
|
@@ -24,6 +24,9 @@
|
|
|
24
24
|
"name": "Applitools Team",
|
|
25
25
|
"email": "team@applitools.com"
|
|
26
26
|
},
|
|
27
|
+
"aliases": [
|
|
28
|
+
"driver"
|
|
29
|
+
],
|
|
27
30
|
"exports": {
|
|
28
31
|
".": {
|
|
29
32
|
"types": "./types/index.d.ts",
|
|
@@ -73,13 +76,13 @@
|
|
|
73
76
|
}
|
|
74
77
|
},
|
|
75
78
|
"dependencies": {
|
|
76
|
-
"@applitools/logger": "1.1.
|
|
77
|
-
"@applitools/snippets": "2.
|
|
78
|
-
"@applitools/types": "1.
|
|
79
|
-
"@applitools/utils": "1.3.
|
|
79
|
+
"@applitools/logger": "1.1.11",
|
|
80
|
+
"@applitools/snippets": "2.4.1",
|
|
81
|
+
"@applitools/types": "1.5.2",
|
|
82
|
+
"@applitools/utils": "1.3.7"
|
|
80
83
|
},
|
|
81
84
|
"devDependencies": {
|
|
82
|
-
"@applitools/bongo": "^2.1.
|
|
85
|
+
"@applitools/bongo": "^2.1.5",
|
|
83
86
|
"@types/mocha": "^9.1.1",
|
|
84
87
|
"@types/node": "^17.0.31",
|
|
85
88
|
"@typescript-eslint/eslint-plugin": "^5.22.0",
|
package/types/element.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ export declare type ElementState<TElement> = {
|
|
|
5
5
|
contentSize?: types.Size;
|
|
6
6
|
scrollOffset?: types.Location;
|
|
7
7
|
transforms?: any;
|
|
8
|
-
attributes?: Record<string, string>;
|
|
8
|
+
attributes?: Record<string, string | Error>;
|
|
9
9
|
touchPadding?: number;
|
|
10
10
|
containedElements?: Map<TElement, boolean>;
|
|
11
11
|
};
|