@applitools/driver 1.9.2 → 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/element.js +24 -14
- package/package.json +9 -6
- package/types/element.d.ts +1 -1
package/dist/element.js
CHANGED
|
@@ -289,7 +289,7 @@ class Element {
|
|
|
289
289
|
.catch(err => {
|
|
290
290
|
this._logger.warn(`Unable to get the attribute 'contentSize' when looking up 'touchPadding' due to the following error: '${err.message}'`);
|
|
291
291
|
});
|
|
292
|
-
this._state.touchPadding = touchPadding !== null && touchPadding !== void 0 ? touchPadding :
|
|
292
|
+
this._state.touchPadding = touchPadding !== null && touchPadding !== void 0 ? touchPadding : 21;
|
|
293
293
|
this._logger.log('Touch padding set:', this._state.touchPadding);
|
|
294
294
|
}
|
|
295
295
|
}
|
|
@@ -311,8 +311,11 @@ class Element {
|
|
|
311
311
|
async getAttribute(name) {
|
|
312
312
|
var _a;
|
|
313
313
|
// we assumes that attributes are not changed during the session
|
|
314
|
-
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];
|
|
315
317
|
return this._state.attributes[name];
|
|
318
|
+
}
|
|
316
319
|
const value = await this.withRefresh(async () => {
|
|
317
320
|
var _a;
|
|
318
321
|
var _b;
|
|
@@ -322,17 +325,24 @@ class Element {
|
|
|
322
325
|
}
|
|
323
326
|
else {
|
|
324
327
|
this._logger.log(`Extracting "${name}" attribute of native element with selector`, this.selector);
|
|
325
|
-
const value = await this._spec.getElementAttribute(this.driver.target, this.target, name);
|
|
326
328
|
(_a = (_b = this._state).attributes) !== null && _a !== void 0 ? _a : (_b.attributes = {});
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
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
|
+
}
|
|
334
345
|
}
|
|
335
|
-
return value;
|
|
336
346
|
}
|
|
337
347
|
});
|
|
338
348
|
this._logger.log(`Extracted element "${name}" attribute:`, value);
|
|
@@ -370,7 +380,7 @@ class Element {
|
|
|
370
380
|
: utils.geometry.offsetNegative(requiredOffset, currentScrollOffset);
|
|
371
381
|
if (this.driver.isAndroid) {
|
|
372
382
|
remainingOffset = utils.geometry.scale(remainingOffset, this.driver.pixelRatio);
|
|
373
|
-
effectiveRegion = utils.geometry.scale(
|
|
383
|
+
effectiveRegion = utils.geometry.scale(effectiveRegion, this.driver.pixelRatio);
|
|
374
384
|
}
|
|
375
385
|
const actions = [];
|
|
376
386
|
const touchPadding = await this.getTouchPadding();
|
|
@@ -464,10 +474,10 @@ class Element {
|
|
|
464
474
|
await this._spec.performAction(this.driver.target, [].concat(...actions));
|
|
465
475
|
}
|
|
466
476
|
const actualScrollableRegion = await this.getClientRegion();
|
|
467
|
-
this._state.scrollOffset = utils.geometry.offsetNegative(requiredOffset, {
|
|
477
|
+
this._state.scrollOffset = utils.geometry.round(utils.geometry.offsetNegative(requiredOffset, {
|
|
468
478
|
x: scrollableRegion.x - actualScrollableRegion.x,
|
|
469
479
|
y: scrollableRegion.y - actualScrollableRegion.y,
|
|
470
|
-
});
|
|
480
|
+
}));
|
|
471
481
|
return this._state.scrollOffset;
|
|
472
482
|
}
|
|
473
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
|
};
|