@applitools/driver 1.9.18 → 1.9.19
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 +1 -1
- package/dist/helper-android.js +26 -41
- package/package.json +1 -1
- package/types/helper-android.d.ts +3 -2
package/dist/element.js
CHANGED
|
@@ -311,7 +311,7 @@ class Element {
|
|
|
311
311
|
this._state.touchPadding = await this.driver.helper.getTouchPadding();
|
|
312
312
|
this._logger.log('Touch padding extracted using helper library', this._state.touchPadding);
|
|
313
313
|
}
|
|
314
|
-
|
|
314
|
+
if (!this._state.touchPadding) {
|
|
315
315
|
this._state.touchPadding = await this.getAttribute('contentSize')
|
|
316
316
|
.then(data => JSON.parse(data).touchPadding)
|
|
317
317
|
.catch(err => {
|
package/dist/helper-android.js
CHANGED
|
@@ -31,6 +31,17 @@ class HelperAndroid {
|
|
|
31
31
|
return null;
|
|
32
32
|
return resourceId.split('/')[1];
|
|
33
33
|
}
|
|
34
|
+
async _command(command) {
|
|
35
|
+
await this._input.type(command);
|
|
36
|
+
await this._input.click();
|
|
37
|
+
let text = await this._input.getText();
|
|
38
|
+
if (this._action && text === command) {
|
|
39
|
+
await this._action.type('1').catch(() => null);
|
|
40
|
+
text = await this._input.getText();
|
|
41
|
+
}
|
|
42
|
+
await this._input.type('');
|
|
43
|
+
return text;
|
|
44
|
+
}
|
|
34
45
|
async getContentRegion(element) {
|
|
35
46
|
let contentHeightString;
|
|
36
47
|
if (this._legacy) {
|
|
@@ -41,13 +52,7 @@ class HelperAndroid {
|
|
|
41
52
|
const elementId = await this._getElementId(element);
|
|
42
53
|
if (!elementId)
|
|
43
54
|
return null;
|
|
44
|
-
await this.
|
|
45
|
-
if (this._action)
|
|
46
|
-
await this._action.type('1');
|
|
47
|
-
else
|
|
48
|
-
await this._input.click();
|
|
49
|
-
contentHeightString = await this._input.getText();
|
|
50
|
-
await this._input.type('');
|
|
55
|
+
contentHeightString = await this._command(`offset;${elementId};0;0;0`);
|
|
51
56
|
}
|
|
52
57
|
const region = await this._spec.getElementRegion(this._input.driver.target, element.target);
|
|
53
58
|
const contentHeight = Number(contentHeightString);
|
|
@@ -55,19 +60,24 @@ class HelperAndroid {
|
|
|
55
60
|
? { x: region.x, y: region.y, width: region.width, height: contentHeight }
|
|
56
61
|
: null;
|
|
57
62
|
}
|
|
63
|
+
async getTouchPadding() {
|
|
64
|
+
if (this._legacy)
|
|
65
|
+
return null;
|
|
66
|
+
const touchPaddingString = await this._command(`getTouchPadding;0;0;0;0`);
|
|
67
|
+
const touchPadding = Number(touchPaddingString);
|
|
68
|
+
if (!touchPadding || Number.isNaN(touchPadding))
|
|
69
|
+
return null;
|
|
70
|
+
return touchPadding;
|
|
71
|
+
}
|
|
58
72
|
async getRegion(element) {
|
|
59
73
|
if (this._legacy)
|
|
60
74
|
return null;
|
|
61
75
|
const elementId = await this._getElementId(element);
|
|
62
76
|
if (!elementId)
|
|
63
77
|
return null;
|
|
64
|
-
await this.
|
|
65
|
-
if (
|
|
66
|
-
|
|
67
|
-
else
|
|
68
|
-
await this._input.click();
|
|
69
|
-
const regionString = await this._input.getText();
|
|
70
|
-
await this._input.type('');
|
|
78
|
+
const regionString = await this._command(`getRect;${elementId};0;0`);
|
|
79
|
+
if (!regionString)
|
|
80
|
+
return null;
|
|
71
81
|
const [, x, y, height, width] = regionString.match(/\[(-?\d+(?:\.\d+)?);(-?\d+(?:\.\d+)?);(-?\d+(?:\.\d+)?);(-?\d+(?:\.\d+)?)\]/);
|
|
72
82
|
const region = { x: Number(x), y: Number(y), width: Number(width), height: Number(height) };
|
|
73
83
|
if (Number.isNaN(region.x + region.y + region.width + region.height))
|
|
@@ -80,12 +90,7 @@ class HelperAndroid {
|
|
|
80
90
|
const elementId = await this._getElementId(element);
|
|
81
91
|
if (!elementId)
|
|
82
92
|
return null;
|
|
83
|
-
await this.
|
|
84
|
-
if (this._action)
|
|
85
|
-
await this._action.type('1');
|
|
86
|
-
else
|
|
87
|
-
await this._input.click();
|
|
88
|
-
await this._input.type('');
|
|
93
|
+
await this._command(`moveToTop;${elementId};0;-1`);
|
|
89
94
|
}
|
|
90
95
|
async scrollBy(element, offset) {
|
|
91
96
|
if (this._legacy)
|
|
@@ -93,27 +98,7 @@ class HelperAndroid {
|
|
|
93
98
|
const elementId = await this._getElementId(element);
|
|
94
99
|
if (!elementId)
|
|
95
100
|
return null;
|
|
96
|
-
await this.
|
|
97
|
-
if (this._action)
|
|
98
|
-
await this._action.type('1');
|
|
99
|
-
else
|
|
100
|
-
await this._input.click();
|
|
101
|
-
await this._input.type('');
|
|
102
|
-
}
|
|
103
|
-
async getTouchPadding() {
|
|
104
|
-
if (this._legacy)
|
|
105
|
-
return null;
|
|
106
|
-
await this._input.type(`getTouchPadding;0;0;0;0`);
|
|
107
|
-
if (this._action)
|
|
108
|
-
await this._action.type('1');
|
|
109
|
-
else
|
|
110
|
-
await this._input.click();
|
|
111
|
-
const touchPaddingString = await this._input.getText();
|
|
112
|
-
await this._input.type('');
|
|
113
|
-
const touchPadding = Number(touchPaddingString);
|
|
114
|
-
if (!touchPadding || Number.isNaN(touchPadding))
|
|
115
|
-
return null;
|
|
116
|
-
return touchPadding;
|
|
101
|
+
await this._command(`scroll;${elementId};${offset.y};0;0`);
|
|
117
102
|
}
|
|
118
103
|
}
|
|
119
104
|
exports.HelperAndroid = HelperAndroid;
|
package/package.json
CHANGED
|
@@ -21,10 +21,11 @@ export declare class HelperAndroid<TDriver, TContext, TElement, TSelector> {
|
|
|
21
21
|
legacy: boolean;
|
|
22
22
|
logger?: any;
|
|
23
23
|
});
|
|
24
|
-
_getElementId
|
|
24
|
+
private _getElementId;
|
|
25
|
+
private _command;
|
|
25
26
|
getContentRegion(element: Element<TDriver, TContext, TElement, TSelector>): Promise<types.Region>;
|
|
27
|
+
getTouchPadding(): Promise<number>;
|
|
26
28
|
getRegion(element: Element<TDriver, TContext, TElement, TSelector>): Promise<types.Region>;
|
|
27
29
|
scrollToTop(element: Element<TDriver, TContext, TElement, TSelector>): Promise<void>;
|
|
28
30
|
scrollBy(element: Element<TDriver, TContext, TElement, TSelector>, offset: types.Location): Promise<void>;
|
|
29
|
-
getTouchPadding(): Promise<number>;
|
|
30
31
|
}
|