@applitools/driver 1.9.3 → 1.9.4
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 +23 -9
- package/dist/helper-android.js +30 -0
- package/dist/helper-ios.js +1 -0
- package/package.json +5 -5
- package/types/helper-android.d.ts +4 -0
- package/types/helper-ios.d.ts +1 -0
package/dist/element.js
CHANGED
|
@@ -278,18 +278,24 @@ class Element {
|
|
|
278
278
|
});
|
|
279
279
|
}
|
|
280
280
|
async getTouchPadding() {
|
|
281
|
+
var _a, _b;
|
|
281
282
|
if (this._state.touchPadding == null) {
|
|
282
283
|
if (this.driver.isWeb)
|
|
283
284
|
this._state.touchPadding = 0;
|
|
284
285
|
else if (this.driver.isIOS)
|
|
285
286
|
this._state.touchPadding = 10;
|
|
286
287
|
else if (this.driver.isAndroid) {
|
|
287
|
-
|
|
288
|
-
.
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
288
|
+
if (((_a = this.driver.helper) === null || _a === void 0 ? void 0 : _a.name) === 'android') {
|
|
289
|
+
this._state.touchPadding = await ((_b = this.driver.helper) === null || _b === void 0 ? void 0 : _b.getTouchPadding());
|
|
290
|
+
}
|
|
291
|
+
else {
|
|
292
|
+
const touchPadding = await this.getAttribute('contentSize')
|
|
293
|
+
.then(data => JSON.parse(data).touchPadding)
|
|
294
|
+
.catch(err => {
|
|
295
|
+
this._logger.warn(`Unable to get the attribute 'contentSize' when looking up 'touchPadding' due to the following error: '${err.message}'`);
|
|
296
|
+
});
|
|
297
|
+
this._state.touchPadding = touchPadding !== null && touchPadding !== void 0 ? touchPadding : 20;
|
|
298
|
+
}
|
|
293
299
|
this._logger.log('Touch padding set:', this._state.touchPadding);
|
|
294
300
|
}
|
|
295
301
|
}
|
|
@@ -355,6 +361,7 @@ class Element {
|
|
|
355
361
|
}
|
|
356
362
|
async scrollTo(offset, options) {
|
|
357
363
|
return this.withRefresh(async () => {
|
|
364
|
+
var _a;
|
|
358
365
|
offset = utils.geometry.round({ x: Math.max(offset.x, 0), y: Math.max(offset.y, 0) });
|
|
359
366
|
if (this.driver.isWeb) {
|
|
360
367
|
let actualOffset = await this.context.execute(snippets.scrollTo, [this, offset]);
|
|
@@ -374,17 +381,23 @@ class Element {
|
|
|
374
381
|
y: Math.round(scrollableRegion.height * (contentSize.height / scrollableRegion.height - 1)),
|
|
375
382
|
};
|
|
376
383
|
const requiredOffset = { x: Math.min(offset.x, maxOffset.x), y: Math.min(offset.y, maxOffset.y) };
|
|
384
|
+
if (((_a = this.driver.helper) === null || _a === void 0 ? void 0 : _a.name) === 'android' && utils.geometry.equals(requiredOffset, { x: 0, y: 0 })) {
|
|
385
|
+
await this.driver.helper.scrollToTop(this);
|
|
386
|
+
this._state.scrollOffset = requiredOffset;
|
|
387
|
+
return this._state.scrollOffset;
|
|
388
|
+
}
|
|
377
389
|
let effectiveRegion = scrollableRegion;
|
|
378
390
|
let remainingOffset = utils.geometry.equals(requiredOffset, { x: 0, y: 0 })
|
|
379
391
|
? { x: -maxOffset.x, y: -maxOffset.y } // if it has to be scrolled to the very beginning, then scroll maximum amount of pixels
|
|
380
392
|
: utils.geometry.offsetNegative(requiredOffset, currentScrollOffset);
|
|
381
393
|
if (this.driver.isAndroid) {
|
|
382
|
-
remainingOffset = utils.geometry.scale(remainingOffset, this.driver.pixelRatio);
|
|
383
|
-
effectiveRegion = utils.geometry.scale(effectiveRegion, this.driver.pixelRatio);
|
|
394
|
+
remainingOffset = utils.geometry.round(utils.geometry.scale(remainingOffset, this.driver.pixelRatio));
|
|
395
|
+
effectiveRegion = utils.geometry.round(utils.geometry.scale(effectiveRegion, this.driver.pixelRatio));
|
|
384
396
|
}
|
|
385
397
|
const actions = [];
|
|
386
|
-
const touchPadding = await this.getTouchPadding();
|
|
387
398
|
const isPager = await this.isPager();
|
|
399
|
+
const touchPadding = await this.getTouchPadding();
|
|
400
|
+
// horizontal scrolling
|
|
388
401
|
const xPadding = Math.max(Math.floor(effectiveRegion.width * 0.07), touchPadding);
|
|
389
402
|
const yTrack = Math.floor(effectiveRegion.y + effectiveRegion.height / 2); // center
|
|
390
403
|
const xLeft = effectiveRegion.y + xPadding;
|
|
@@ -424,6 +437,7 @@ class Element {
|
|
|
424
437
|
}
|
|
425
438
|
xRemaining -= xRight - xLeft;
|
|
426
439
|
}
|
|
440
|
+
// vertical scrolling
|
|
427
441
|
const yPadding = Math.max(Math.floor(effectiveRegion.height * 0.07), touchPadding);
|
|
428
442
|
const xTrack = Math.floor(effectiveRegion.x + 5); // a little bit off left border
|
|
429
443
|
const yBottom = effectiveRegion.y + effectiveRegion.height - yPadding;
|
package/dist/helper-android.js
CHANGED
|
@@ -7,6 +7,7 @@ class HelperAndroid {
|
|
|
7
7
|
this._element = options.element;
|
|
8
8
|
this._legacy = options.legacy;
|
|
9
9
|
this._logger = options.logger;
|
|
10
|
+
this.name = this._legacy ? 'android-legacy' : 'android';
|
|
10
11
|
}
|
|
11
12
|
static async make(options) {
|
|
12
13
|
const { spec, driver, logger } = options;
|
|
@@ -64,5 +65,34 @@ class HelperAndroid {
|
|
|
64
65
|
return null;
|
|
65
66
|
return region;
|
|
66
67
|
}
|
|
68
|
+
async scrollToTop(element) {
|
|
69
|
+
if (this._legacy)
|
|
70
|
+
return null;
|
|
71
|
+
const elementId = await this._getElementId(element);
|
|
72
|
+
if (!elementId)
|
|
73
|
+
return null;
|
|
74
|
+
await this._element.type(`moveToTop;${elementId};0;0`);
|
|
75
|
+
await this._element.click();
|
|
76
|
+
await this._element.type('');
|
|
77
|
+
}
|
|
78
|
+
async scrollBy(element, offset) {
|
|
79
|
+
if (this._legacy)
|
|
80
|
+
return null;
|
|
81
|
+
const elementId = await this._getElementId(element);
|
|
82
|
+
if (!elementId)
|
|
83
|
+
return null;
|
|
84
|
+
await this._element.type(`scroll;${elementId};${offset.y};0;0`);
|
|
85
|
+
await this._element.click();
|
|
86
|
+
await this._element.type('');
|
|
87
|
+
}
|
|
88
|
+
async getTouchPadding() {
|
|
89
|
+
if (this._legacy)
|
|
90
|
+
return null;
|
|
91
|
+
await this._element.type(`getTouchPadding;0;0;0;0`);
|
|
92
|
+
await this._element.click();
|
|
93
|
+
const touchPaddingString = await this._element.getText();
|
|
94
|
+
await this._element.type('');
|
|
95
|
+
return Number(touchPaddingString);
|
|
96
|
+
}
|
|
67
97
|
}
|
|
68
98
|
exports.HelperAndroid = HelperAndroid;
|
package/dist/helper-ios.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@applitools/driver",
|
|
3
|
-
"version": "1.9.
|
|
3
|
+
"version": "1.9.4",
|
|
4
4
|
"description": "Applitools universal framework wrapper",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"applitools",
|
|
@@ -76,10 +76,10 @@
|
|
|
76
76
|
}
|
|
77
77
|
},
|
|
78
78
|
"dependencies": {
|
|
79
|
-
"@applitools/logger": "1.1.
|
|
80
|
-
"@applitools/snippets": "2.4.
|
|
81
|
-
"@applitools/types": "1.5.
|
|
82
|
-
"@applitools/utils": "1.3.
|
|
79
|
+
"@applitools/logger": "1.1.12",
|
|
80
|
+
"@applitools/snippets": "2.4.2",
|
|
81
|
+
"@applitools/types": "1.5.3",
|
|
82
|
+
"@applitools/utils": "1.3.8"
|
|
83
83
|
},
|
|
84
84
|
"devDependencies": {
|
|
85
85
|
"@applitools/bongo": "^2.1.5",
|
|
@@ -12,6 +12,7 @@ export declare class HelperAndroid<TDriver, TContext, TElement, TSelector> {
|
|
|
12
12
|
private readonly _element;
|
|
13
13
|
private readonly _legacy;
|
|
14
14
|
private _logger;
|
|
15
|
+
readonly name: 'android' | 'android-legacy';
|
|
15
16
|
constructor(options: {
|
|
16
17
|
spec: types.SpecDriver<TDriver, TContext, TElement, TSelector>;
|
|
17
18
|
element: Element<TDriver, TContext, TElement, TSelector>;
|
|
@@ -21,4 +22,7 @@ export declare class HelperAndroid<TDriver, TContext, TElement, TSelector> {
|
|
|
21
22
|
_getElementId(element: Element<TDriver, TContext, TElement, TSelector>): Promise<string>;
|
|
22
23
|
getContentSize(element: Element<TDriver, TContext, TElement, TSelector>): Promise<types.Size>;
|
|
23
24
|
getRegion(element: Element<TDriver, TContext, TElement, TSelector>): Promise<types.Region>;
|
|
25
|
+
scrollToTop(element: Element<TDriver, TContext, TElement, TSelector>): Promise<void>;
|
|
26
|
+
scrollBy(element: Element<TDriver, TContext, TElement, TSelector>, offset: types.Location): Promise<void>;
|
|
27
|
+
getTouchPadding(): Promise<number>;
|
|
24
28
|
}
|
package/types/helper-ios.d.ts
CHANGED
|
@@ -12,6 +12,7 @@ export declare class HelperIOS<TDriver, TContext, TElement, TSelector> {
|
|
|
12
12
|
private readonly _element;
|
|
13
13
|
private readonly _spec;
|
|
14
14
|
private _logger;
|
|
15
|
+
readonly name: 'ios';
|
|
15
16
|
constructor(options: {
|
|
16
17
|
driver: Driver<TDriver, TContext, TElement, TSelector>;
|
|
17
18
|
element: Element<TDriver, TContext, TElement, TSelector>;
|