@applitools/driver 1.9.9 → 1.9.12
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/helper-android.js +47 -32
- package/dist/spec-utils.js +4 -2
- package/package.json +10 -8
- package/types/helper-android.d.ts +4 -2
package/dist/helper-android.js
CHANGED
|
@@ -28,7 +28,8 @@ const utils = __importStar(require("@applitools/utils"));
|
|
|
28
28
|
class HelperAndroid {
|
|
29
29
|
constructor(options) {
|
|
30
30
|
this._spec = options.spec;
|
|
31
|
-
this.
|
|
31
|
+
this._input = options.input;
|
|
32
|
+
this._action = options.action;
|
|
32
33
|
this._legacy = options.legacy;
|
|
33
34
|
this._logger = options.logger;
|
|
34
35
|
this.name = this._legacy ? 'android-legacy' : 'android';
|
|
@@ -36,18 +37,17 @@ class HelperAndroid {
|
|
|
36
37
|
static async make(options) {
|
|
37
38
|
const { spec, driver, logger } = options;
|
|
38
39
|
let legacy = false;
|
|
39
|
-
let
|
|
40
|
-
|
|
41
|
-
selector: '//*[@content-desc="EyesAppiumHelperEDT"]',
|
|
42
|
-
});
|
|
43
|
-
if (!element) {
|
|
40
|
+
let input = await driver.element({ type: 'xpath', selector: '//*[@content-desc="EyesAppiumHelperEDT"]' });
|
|
41
|
+
if (!input) {
|
|
44
42
|
legacy = true;
|
|
45
|
-
|
|
46
|
-
type: '-android uiautomator',
|
|
47
|
-
selector: 'new UiSelector().description("EyesAppiumHelper")',
|
|
48
|
-
});
|
|
43
|
+
input = await driver.element({ type: 'xpath', selector: '//*[@content-desc="EyesAppiumHelper"]' });
|
|
49
44
|
}
|
|
50
|
-
|
|
45
|
+
const action = !legacy
|
|
46
|
+
? await driver.element({ type: 'xpath', selector: '//*[@content-desc="EyesAppiumHelper_Action"]' })
|
|
47
|
+
: null;
|
|
48
|
+
return input
|
|
49
|
+
? new HelperAndroid({ spec, input, action, legacy, logger })
|
|
50
|
+
: null;
|
|
51
51
|
}
|
|
52
52
|
async _getElementId(element) {
|
|
53
53
|
const resourceId = await element.getAttribute('resource-id');
|
|
@@ -58,19 +58,22 @@ class HelperAndroid {
|
|
|
58
58
|
async getContentSize(element) {
|
|
59
59
|
let contentHeightString;
|
|
60
60
|
if (this._legacy) {
|
|
61
|
-
await this.
|
|
62
|
-
contentHeightString = await this.
|
|
61
|
+
await this._input.click();
|
|
62
|
+
contentHeightString = await this._input.getText();
|
|
63
63
|
}
|
|
64
64
|
else {
|
|
65
65
|
const elementId = await this._getElementId(element);
|
|
66
66
|
if (!elementId)
|
|
67
67
|
return null;
|
|
68
|
-
await this.
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
68
|
+
await this._input.type(`offset;${elementId};0;0;0`);
|
|
69
|
+
if (this._action)
|
|
70
|
+
await this._action.type('1');
|
|
71
|
+
else
|
|
72
|
+
await this._input.click();
|
|
73
|
+
contentHeightString = await this._input.getText();
|
|
74
|
+
await this._input.type('');
|
|
72
75
|
}
|
|
73
|
-
const region = await this._spec.getElementRegion(this.
|
|
76
|
+
const region = await this._spec.getElementRegion(this._input.driver.target, element.target);
|
|
74
77
|
const contentHeight = Number(contentHeightString);
|
|
75
78
|
if (Number.isNaN(contentHeight))
|
|
76
79
|
return utils.geometry.size(region);
|
|
@@ -82,10 +85,13 @@ class HelperAndroid {
|
|
|
82
85
|
const elementId = await this._getElementId(element);
|
|
83
86
|
if (!elementId)
|
|
84
87
|
return null;
|
|
85
|
-
await this.
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
88
|
+
await this._input.type(`getRect;${elementId};0;0`);
|
|
89
|
+
if (this._action)
|
|
90
|
+
await this._action.type('1');
|
|
91
|
+
else
|
|
92
|
+
await this._input.click();
|
|
93
|
+
const regionString = await this._input.getText();
|
|
94
|
+
await this._input.type('');
|
|
89
95
|
const [, x, y, height, width] = regionString.match(/\[(-?\d+(?:\.\d+)?);(-?\d+(?:\.\d+)?);(-?\d+(?:\.\d+)?);(-?\d+(?:\.\d+)?)\]/);
|
|
90
96
|
const region = { x: Number(x), y: Number(y), width: Number(width), height: Number(height) };
|
|
91
97
|
if (Number.isNaN(region.x + region.y + region.width + region.height))
|
|
@@ -98,9 +104,12 @@ class HelperAndroid {
|
|
|
98
104
|
const elementId = await this._getElementId(element);
|
|
99
105
|
if (!elementId)
|
|
100
106
|
return null;
|
|
101
|
-
await this.
|
|
102
|
-
|
|
103
|
-
|
|
107
|
+
await this._input.type(`moveToTop;${elementId};0;-1`);
|
|
108
|
+
if (this._action)
|
|
109
|
+
await this._action.type('1');
|
|
110
|
+
else
|
|
111
|
+
await this._input.click();
|
|
112
|
+
await this._input.type('');
|
|
104
113
|
}
|
|
105
114
|
async scrollBy(element, offset) {
|
|
106
115
|
if (this._legacy)
|
|
@@ -108,17 +117,23 @@ class HelperAndroid {
|
|
|
108
117
|
const elementId = await this._getElementId(element);
|
|
109
118
|
if (!elementId)
|
|
110
119
|
return null;
|
|
111
|
-
await this.
|
|
112
|
-
|
|
113
|
-
|
|
120
|
+
await this._input.type(`scroll;${elementId};${offset.y};0;0`);
|
|
121
|
+
if (this._action)
|
|
122
|
+
await this._action.type('1');
|
|
123
|
+
else
|
|
124
|
+
await this._input.click();
|
|
125
|
+
await this._input.type('');
|
|
114
126
|
}
|
|
115
127
|
async getTouchPadding() {
|
|
116
128
|
if (this._legacy)
|
|
117
129
|
return null;
|
|
118
|
-
await this.
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
130
|
+
await this._input.type(`getTouchPadding;0;0;0;0`);
|
|
131
|
+
if (this._action)
|
|
132
|
+
await this._action.type('1');
|
|
133
|
+
else
|
|
134
|
+
await this._input.click();
|
|
135
|
+
const touchPaddingString = await this._input.getText();
|
|
136
|
+
await this._input.type('');
|
|
122
137
|
const touchPadding = Number(touchPaddingString);
|
|
123
138
|
if (Number.isNaN(touchPadding))
|
|
124
139
|
return null;
|
package/dist/spec-utils.js
CHANGED
|
@@ -40,10 +40,12 @@ function transformSelector(spec, selector, environment) {
|
|
|
40
40
|
if ((environment === null || environment === void 0 ? void 0 : environment.isWeb) && isCommonSelector(spec, selector)) {
|
|
41
41
|
if (selector.type === 'id')
|
|
42
42
|
selector = { type: 'css', selector: `#${selector.selector}` };
|
|
43
|
-
if (selector.type === 'name')
|
|
43
|
+
else if (selector.type === 'name')
|
|
44
44
|
selector = { type: 'css', selector: `[name="${selector.selector}"]` };
|
|
45
|
-
if (selector.type === 'class name')
|
|
45
|
+
else if (selector.type === 'class name')
|
|
46
46
|
selector = { type: 'css', selector: `.${selector.selector}` };
|
|
47
|
+
else if (selector.type === 'tag name')
|
|
48
|
+
selector = { type: 'css', selector: `${selector.selector}` };
|
|
47
49
|
}
|
|
48
50
|
return (_b = (_a = spec.transformSelector) === null || _a === void 0 ? void 0 : _a.call(spec, selector)) !== null && _b !== void 0 ? _b : selector;
|
|
49
51
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@applitools/driver",
|
|
3
|
-
"version": "1.9.
|
|
3
|
+
"version": "1.9.12",
|
|
4
4
|
"description": "Applitools universal framework wrapper",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"applitools",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"repository": {
|
|
18
18
|
"type": "git",
|
|
19
19
|
"url": "git://github.com/applitools/eyes.sdk.javascript1.git",
|
|
20
|
-
"directory": "packages/driver"
|
|
20
|
+
"directory": "js/packages/driver"
|
|
21
21
|
},
|
|
22
22
|
"license": "SEE LICENSE IN LICENSE",
|
|
23
23
|
"author": {
|
|
@@ -64,7 +64,9 @@
|
|
|
64
64
|
"scripts": {
|
|
65
65
|
"lint": "eslint '**/*.ts'",
|
|
66
66
|
"build": "tsc",
|
|
67
|
-
"test": "
|
|
67
|
+
"test": "yarn test:unit",
|
|
68
|
+
"test:sanity": "yarn test:unit",
|
|
69
|
+
"test:unit": "mocha --no-timeouts -r ts-node/register ./test/unit/*.spec.ts",
|
|
68
70
|
"deps": "bongo deps",
|
|
69
71
|
"preversion": "bongo preversion",
|
|
70
72
|
"version": "bongo version",
|
|
@@ -76,13 +78,13 @@
|
|
|
76
78
|
}
|
|
77
79
|
},
|
|
78
80
|
"dependencies": {
|
|
79
|
-
"@applitools/logger": "1.1.
|
|
80
|
-
"@applitools/snippets": "2.4.
|
|
81
|
-
"@applitools/types": "1.5.
|
|
82
|
-
"@applitools/utils": "1.3.
|
|
81
|
+
"@applitools/logger": "1.1.14",
|
|
82
|
+
"@applitools/snippets": "2.4.4",
|
|
83
|
+
"@applitools/types": "1.5.6",
|
|
84
|
+
"@applitools/utils": "1.3.10"
|
|
83
85
|
},
|
|
84
86
|
"devDependencies": {
|
|
85
|
-
"@applitools/bongo": "^2.1.
|
|
87
|
+
"@applitools/bongo": "^2.1.6",
|
|
86
88
|
"@types/mocha": "^9.1.1",
|
|
87
89
|
"@types/node": "^17.0.31",
|
|
88
90
|
"@typescript-eslint/eslint-plugin": "^5.22.0",
|
|
@@ -9,13 +9,15 @@ export declare class HelperAndroid<TDriver, TContext, TElement, TSelector> {
|
|
|
9
9
|
logger: Logger;
|
|
10
10
|
}): Promise<HelperAndroid<TDriver, TContext, TElement, TSelector> | null>;
|
|
11
11
|
private readonly _spec;
|
|
12
|
-
private readonly
|
|
12
|
+
private readonly _input;
|
|
13
|
+
private readonly _action?;
|
|
13
14
|
private readonly _legacy;
|
|
14
15
|
private _logger;
|
|
15
16
|
readonly name: 'android' | 'android-legacy';
|
|
16
17
|
constructor(options: {
|
|
17
18
|
spec: types.SpecDriver<TDriver, TContext, TElement, TSelector>;
|
|
18
|
-
|
|
19
|
+
input: Element<TDriver, TContext, TElement, TSelector>;
|
|
20
|
+
action?: Element<TDriver, TContext, TElement, TSelector>;
|
|
19
21
|
legacy: boolean;
|
|
20
22
|
logger?: any;
|
|
21
23
|
});
|