@applitools/driver 1.9.17 → 1.9.20
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 +11 -5
- package/dist/helper-android.js +26 -41
- package/dist/spec-utils.js +7 -1
- package/package.json +3 -3
- package/types/helper-android.d.ts +3 -2
- package/types/spec-utils.d.ts +1 -0
package/dist/element.js
CHANGED
|
@@ -50,7 +50,10 @@ class Element {
|
|
|
50
50
|
else {
|
|
51
51
|
throw new TypeError('Element constructor called with argument of unknown type!');
|
|
52
52
|
}
|
|
53
|
-
if (this._selector
|
|
53
|
+
if (specUtils.isSimpleCommonSelector(this._selector)) {
|
|
54
|
+
this._commonSelector = this._selector;
|
|
55
|
+
}
|
|
56
|
+
else if (this._selector && this._spec.untransformSelector) {
|
|
54
57
|
this._commonSelector = this._spec.untransformSelector(this._spec.transformSelector(this._selector));
|
|
55
58
|
}
|
|
56
59
|
}
|
|
@@ -297,6 +300,7 @@ class Element {
|
|
|
297
300
|
}
|
|
298
301
|
async getTouchPadding() {
|
|
299
302
|
var _a, _b;
|
|
303
|
+
var _c;
|
|
300
304
|
if (this._state.touchPadding == null) {
|
|
301
305
|
if (this.driver.isWeb)
|
|
302
306
|
this._state.touchPadding = 0;
|
|
@@ -304,16 +308,18 @@ class Element {
|
|
|
304
308
|
this._state.touchPadding = 10;
|
|
305
309
|
else if (this.driver.isAndroid) {
|
|
306
310
|
if (((_a = this.driver.helper) === null || _a === void 0 ? void 0 : _a.name) === 'android') {
|
|
307
|
-
this._state.touchPadding =
|
|
311
|
+
this._state.touchPadding = await this.driver.helper.getTouchPadding();
|
|
312
|
+
this._logger.log('Touch padding extracted using helper library', this._state.touchPadding);
|
|
308
313
|
}
|
|
309
|
-
|
|
310
|
-
|
|
314
|
+
if (!this._state.touchPadding) {
|
|
315
|
+
this._state.touchPadding = await this.getAttribute('contentSize')
|
|
311
316
|
.then(data => JSON.parse(data).touchPadding)
|
|
312
317
|
.catch(err => {
|
|
313
318
|
this._logger.warn(`Unable to get the attribute 'contentSize' when looking up 'touchPadding' due to the following error: '${err.message}'`);
|
|
314
319
|
});
|
|
315
|
-
this.
|
|
320
|
+
this._logger.log('Touch padding extracted using attribute', this._state.touchPadding);
|
|
316
321
|
}
|
|
322
|
+
(_b = (_c = this._state).touchPadding) !== null && _b !== void 0 ? _b : (_c.touchPadding = 20);
|
|
317
323
|
this._logger.log('Touch padding set:', this._state.touchPadding);
|
|
318
324
|
}
|
|
319
325
|
}
|
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 (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/dist/spec-utils.js
CHANGED
|
@@ -23,8 +23,14 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.withFastCache = exports.splitSelector = exports.transformSelector = exports.isSelector = exports.isCommonSelector = void 0;
|
|
26
|
+
exports.withFastCache = exports.splitSelector = exports.transformSelector = exports.isSelector = exports.isCommonSelector = exports.isSimpleCommonSelector = void 0;
|
|
27
27
|
const utils = __importStar(require("@applitools/utils"));
|
|
28
|
+
function isSimpleCommonSelector(selector) {
|
|
29
|
+
return (utils.types.isPlainObject(selector) &&
|
|
30
|
+
utils.types.has(selector, 'selector') &&
|
|
31
|
+
utils.types.isString(selector.selector));
|
|
32
|
+
}
|
|
33
|
+
exports.isSimpleCommonSelector = isSimpleCommonSelector;
|
|
28
34
|
function isCommonSelector(spec, selector) {
|
|
29
35
|
return (utils.types.isPlainObject(selector) &&
|
|
30
36
|
utils.types.has(selector, 'selector') &&
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@applitools/driver",
|
|
3
|
-
"version": "1.9.
|
|
3
|
+
"version": "1.9.20",
|
|
4
4
|
"description": "Applitools universal framework wrapper",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"applitools",
|
|
@@ -79,8 +79,8 @@
|
|
|
79
79
|
},
|
|
80
80
|
"dependencies": {
|
|
81
81
|
"@applitools/logger": "1.1.15",
|
|
82
|
-
"@applitools/snippets": "2.4.
|
|
83
|
-
"@applitools/types": "1.5.
|
|
82
|
+
"@applitools/snippets": "2.4.5",
|
|
83
|
+
"@applitools/types": "1.5.8",
|
|
84
84
|
"@applitools/utils": "1.3.10"
|
|
85
85
|
},
|
|
86
86
|
"devDependencies": {
|
|
@@ -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
|
}
|
package/types/spec-utils.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ declare type CommonSelector<TSelector = never> = {
|
|
|
5
5
|
shadow?: CommonSelector<TSelector> | TSelector | string;
|
|
6
6
|
frame?: CommonSelector<TSelector> | TSelector | string;
|
|
7
7
|
};
|
|
8
|
+
export declare function isSimpleCommonSelector(selector: any): selector is CommonSelector;
|
|
8
9
|
export declare function isCommonSelector<TSelector>(spec: Pick<types.SpecDriver<unknown, unknown, unknown, TSelector>, 'isSelector'>, selector: any): selector is CommonSelector<TSelector>;
|
|
9
10
|
export declare function isSelector<TSelector>(spec: Pick<types.SpecDriver<unknown, unknown, unknown, TSelector>, 'isSelector'>, selector: any): selector is types.Selector<TSelector>;
|
|
10
11
|
export declare function transformSelector<TSelector>(spec: Pick<types.SpecDriver<unknown, unknown, unknown, TSelector>, 'isSelector' | 'transformSelector'>, selector: types.Selector<TSelector>, environment?: {
|