appium-uiautomator2-driver 2.42.2 → 2.43.0
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/CHANGELOG.md +7 -0
- package/build/lib/commands/actions.d.ts +22 -1
- package/build/lib/commands/actions.d.ts.map +1 -1
- package/build/lib/commands/actions.js +30 -62
- package/build/lib/commands/actions.js.map +1 -1
- package/build/lib/commands/alert.d.ts +28 -1
- package/build/lib/commands/alert.d.ts.map +1 -1
- package/build/lib/commands/alert.js +42 -23
- package/build/lib/commands/alert.js.map +1 -1
- package/build/lib/commands/app-management.d.ts +19 -0
- package/build/lib/commands/app-management.d.ts.map +1 -0
- package/build/lib/commands/app-management.js +45 -0
- package/build/lib/commands/app-management.js.map +1 -0
- package/build/lib/commands/app-strings.d.ts +9 -0
- package/build/lib/commands/app-strings.d.ts.map +1 -1
- package/build/lib/commands/app-strings.js +11 -79
- package/build/lib/commands/app-strings.js.map +1 -1
- package/build/lib/commands/battery.d.ts +7 -0
- package/build/lib/commands/battery.d.ts.map +1 -1
- package/build/lib/commands/battery.js +14 -20
- package/build/lib/commands/battery.js.map +1 -1
- package/build/lib/commands/element.d.ts +100 -1
- package/build/lib/commands/element.d.ts.map +1 -1
- package/build/lib/commands/element.js +175 -125
- package/build/lib/commands/element.js.map +1 -1
- package/build/lib/commands/execute.d.ts +25 -0
- package/build/lib/commands/execute.d.ts.map +1 -0
- package/build/lib/commands/execute.js +109 -0
- package/build/lib/commands/execute.js.map +1 -0
- package/build/lib/commands/find.d.ts +10 -0
- package/build/lib/commands/find.d.ts.map +1 -1
- package/build/lib/commands/find.js +25 -27
- package/build/lib/commands/find.js.map +1 -1
- package/build/lib/commands/gestures.d.ts +103 -1
- package/build/lib/commands/gestures.d.ts.map +1 -1
- package/build/lib/commands/gestures.js +202 -173
- package/build/lib/commands/gestures.js.map +1 -1
- package/build/lib/commands/keyboard.d.ts +47 -0
- package/build/lib/commands/keyboard.d.ts.map +1 -0
- package/build/lib/commands/keyboard.js +92 -0
- package/build/lib/commands/keyboard.js.map +1 -0
- package/build/lib/commands/misc.d.ts +48 -0
- package/build/lib/commands/misc.d.ts.map +1 -0
- package/build/lib/commands/misc.js +75 -0
- package/build/lib/commands/misc.js.map +1 -0
- package/build/lib/commands/navigation.d.ts +20 -0
- package/build/lib/commands/navigation.d.ts.map +1 -0
- package/build/lib/commands/navigation.js +35 -0
- package/build/lib/commands/navigation.js.map +1 -0
- package/build/lib/commands/screenshot.d.ts +24 -1
- package/build/lib/commands/screenshot.d.ts.map +1 -1
- package/build/lib/commands/screenshot.js +87 -64
- package/build/lib/commands/screenshot.js.map +1 -1
- package/build/lib/commands/touch.d.ts +81 -0
- package/build/lib/commands/touch.d.ts.map +1 -1
- package/build/lib/commands/touch.js +158 -41
- package/build/lib/commands/touch.js.map +1 -1
- package/build/lib/commands/viewport.d.ts +37 -1
- package/build/lib/commands/viewport.d.ts.map +1 -1
- package/build/lib/commands/viewport.js +80 -36
- package/build/lib/commands/viewport.js.map +1 -1
- package/build/lib/driver.d.ts +94 -24
- package/build/lib/driver.d.ts.map +1 -1
- package/build/lib/driver.js +114 -28
- package/build/lib/driver.js.map +1 -1
- package/build/lib/helpers.d.ts +12 -6
- package/build/lib/helpers.d.ts.map +1 -1
- package/build/lib/helpers.js +18 -18
- package/build/lib/helpers.js.map +1 -1
- package/build/lib/method-map.d.ts +0 -23
- package/build/lib/method-map.d.ts.map +1 -1
- package/build/lib/uiautomator2.js +3 -3
- package/build/lib/uiautomator2.js.map +1 -1
- package/build/tsconfig.tsbuildinfo +1 -1
- package/lib/commands/actions.js +37 -114
- package/lib/commands/alert.js +51 -37
- package/lib/commands/app-management.js +42 -0
- package/lib/commands/app-strings.js +9 -89
- package/lib/commands/battery.js +16 -26
- package/lib/commands/element.js +235 -214
- package/lib/commands/execute.js +120 -0
- package/lib/commands/find.js +31 -37
- package/lib/commands/gestures.js +252 -234
- package/lib/commands/keyboard.js +103 -0
- package/lib/commands/misc.js +106 -0
- package/lib/commands/navigation.js +31 -0
- package/lib/commands/screenshot.js +96 -77
- package/lib/commands/touch.js +190 -48
- package/lib/commands/viewport.js +100 -50
- package/lib/driver.ts +225 -36
- package/lib/helpers.js +15 -22
- package/lib/uiautomator2.js +3 -3
- package/npm-shrinkwrap.json +31 -31
- package/package.json +2 -2
- package/build/lib/commands/general.d.ts +0 -4
- package/build/lib/commands/general.d.ts.map +0 -1
- package/build/lib/commands/general.js +0 -214
- package/build/lib/commands/general.js.map +0 -1
- package/build/lib/commands/index.d.ts +0 -2
- package/build/lib/commands/index.d.ts.map +0 -1
- package/build/lib/commands/index.js +0 -14
- package/build/lib/commands/index.js.map +0 -1
- package/build/lib/commands/mixins.d.ts +0 -87
- package/build/lib/commands/mixins.d.ts.map +0 -1
- package/build/lib/commands/mixins.js +0 -26
- package/build/lib/commands/mixins.js.map +0 -1
- package/build/lib/utils.d.ts +0 -10
- package/build/lib/utils.d.ts.map +0 -1
- package/build/lib/utils.js +0 -26
- package/build/lib/utils.js.map +0 -1
- package/lib/commands/general.js +0 -289
- package/lib/commands/index.js +0 -11
- package/lib/commands/mixins.ts +0 -169
- package/lib/utils.js +0 -19
|
@@ -1,2 +1,101 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* @this {AndroidUiautomator2Driver}
|
|
3
|
+
* @returns {Promise<import('@appium/types').Element>}
|
|
4
|
+
*/
|
|
5
|
+
export function active(this: import("../driver").AndroidUiautomator2Driver): Promise<import('@appium/types').Element>;
|
|
6
|
+
/**
|
|
7
|
+
* @this {AndroidUiautomator2Driver}
|
|
8
|
+
* @param {string} attribute
|
|
9
|
+
* @param {string} elementId
|
|
10
|
+
* @returns {Promise<string?>}
|
|
11
|
+
*/
|
|
12
|
+
export function getAttribute(this: import("../driver").AndroidUiautomator2Driver, attribute: string, elementId: string): Promise<string | null>;
|
|
13
|
+
/**
|
|
14
|
+
* @this {AndroidUiautomator2Driver}
|
|
15
|
+
* @param {string} elementId
|
|
16
|
+
* @returns {Promise<boolean>}
|
|
17
|
+
*/
|
|
18
|
+
export function elementDisplayed(this: import("../driver").AndroidUiautomator2Driver, elementId: string): Promise<boolean>;
|
|
19
|
+
/**
|
|
20
|
+
* @this {AndroidUiautomator2Driver}
|
|
21
|
+
* @param {string} elementId
|
|
22
|
+
* @returns {Promise<boolean>}
|
|
23
|
+
*/
|
|
24
|
+
export function elementEnabled(this: import("../driver").AndroidUiautomator2Driver, elementId: string): Promise<boolean>;
|
|
25
|
+
/**
|
|
26
|
+
* @this {AndroidUiautomator2Driver}
|
|
27
|
+
* @param {string} elementId
|
|
28
|
+
* @returns {Promise<boolean>}
|
|
29
|
+
*/
|
|
30
|
+
export function elementSelected(this: import("../driver").AndroidUiautomator2Driver, elementId: string): Promise<boolean>;
|
|
31
|
+
/**
|
|
32
|
+
* @this {AndroidUiautomator2Driver}
|
|
33
|
+
* @param {string} elementId
|
|
34
|
+
* @returns {Promise<string>}
|
|
35
|
+
*/
|
|
36
|
+
export function getName(this: import("../driver").AndroidUiautomator2Driver, elementId: string): Promise<string>;
|
|
37
|
+
/**
|
|
38
|
+
* @this {AndroidUiautomator2Driver}
|
|
39
|
+
* @param {string} elementId
|
|
40
|
+
* @returns {Promise<import('@appium/types').Position>}
|
|
41
|
+
*/
|
|
42
|
+
export function getLocation(this: import("../driver").AndroidUiautomator2Driver, elementId: string): Promise<import('@appium/types').Position>;
|
|
43
|
+
/**
|
|
44
|
+
* @this {AndroidUiautomator2Driver}
|
|
45
|
+
* @param {string} elementId
|
|
46
|
+
* @returns {Promise<import('@appium/types').Size>}
|
|
47
|
+
*/
|
|
48
|
+
export function getSize(this: import("../driver").AndroidUiautomator2Driver, elementId: string): Promise<import('@appium/types').Size>;
|
|
49
|
+
/**
|
|
50
|
+
* @this {AndroidUiautomator2Driver}
|
|
51
|
+
* @param {import('appium-android-driver').DoSetElementValueOpts} params
|
|
52
|
+
* @returns {Promise<void>}
|
|
53
|
+
*/
|
|
54
|
+
export function doSetElementValue(this: import("../driver").AndroidUiautomator2Driver, params: import('appium-android-driver').DoSetElementValueOpts): Promise<void>;
|
|
55
|
+
/**
|
|
56
|
+
* @this {AndroidUiautomator2Driver}
|
|
57
|
+
* @param {string|string[]} keys
|
|
58
|
+
* @param {string} elementId
|
|
59
|
+
* @returns {Promise<void>}
|
|
60
|
+
*/
|
|
61
|
+
export function setValueImmediate(this: import("../driver").AndroidUiautomator2Driver, keys: string | string[], elementId: string): Promise<void>;
|
|
62
|
+
/**
|
|
63
|
+
* @this {AndroidUiautomator2Driver}
|
|
64
|
+
* @param {string} elementId
|
|
65
|
+
* @returns {Promise<string>}
|
|
66
|
+
*/
|
|
67
|
+
export function getText(this: import("../driver").AndroidUiautomator2Driver, elementId: string): Promise<string>;
|
|
68
|
+
/**
|
|
69
|
+
* @this {AndroidUiautomator2Driver}
|
|
70
|
+
* @param {string} element
|
|
71
|
+
* @returns {Promise<void>}
|
|
72
|
+
*/
|
|
73
|
+
export function click(this: import("../driver").AndroidUiautomator2Driver, element: string): Promise<void>;
|
|
74
|
+
/**
|
|
75
|
+
* @this {AndroidUiautomator2Driver}
|
|
76
|
+
* @param {string} element
|
|
77
|
+
* @returns {Promise<string>}
|
|
78
|
+
*/
|
|
79
|
+
export function getElementScreenshot(this: import("../driver").AndroidUiautomator2Driver, element: string): Promise<string>;
|
|
80
|
+
/**
|
|
81
|
+
* @this {AndroidUiautomator2Driver}
|
|
82
|
+
* @param {string} elementId
|
|
83
|
+
* @returns {Promise<void>}
|
|
84
|
+
*/
|
|
85
|
+
export function clear(this: import("../driver").AndroidUiautomator2Driver, elementId: string): Promise<void>;
|
|
86
|
+
/**
|
|
87
|
+
* @this {AndroidUiautomator2Driver}
|
|
88
|
+
* @param {string} elementId
|
|
89
|
+
* @returns {Promise<import('@appium/types').Rect>}
|
|
90
|
+
*/
|
|
91
|
+
export function getElementRect(this: import("../driver").AndroidUiautomator2Driver, elementId: string): Promise<import('@appium/types').Rect>;
|
|
92
|
+
/**
|
|
93
|
+
* Sends text to the given element by replacing its previous content
|
|
94
|
+
* @this {AndroidUiautomator2Driver}
|
|
95
|
+
* @param {import('./types').ReplaceValueOptions} opts
|
|
96
|
+
* @throws {Error} If there was a faulre while setting the text
|
|
97
|
+
* @returns {Promise<void>}
|
|
98
|
+
*/
|
|
99
|
+
export function mobileReplaceElementValue(this: import("../driver").AndroidUiautomator2Driver, opts: import('./types').ReplaceValueOptions): Promise<void>;
|
|
100
|
+
export type AndroidUiautomator2Driver = import('../driver').AndroidUiautomator2Driver;
|
|
2
101
|
//# sourceMappingURL=element.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"element.d.ts","sourceRoot":"","sources":["../../../lib/commands/element.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"element.d.ts","sourceRoot":"","sources":["../../../lib/commands/element.js"],"names":[],"mappings":"AAKA;;;GAGG;AACH,6EAFa,QAAQ,OAAO,eAAe,EAAE,OAAO,CAAC,CASpD;AAED;;;;;GAKG;AACH,6FAJW,MAAM,aACN,MAAM,GACJ,QAAQ,MAAM,QAAE,CAU5B;AAED;;;;GAIG;AACH,iGAHW,MAAM,GACJ,QAAQ,OAAO,CAAC,CAI5B;AAED;;;;GAIG;AACH,+FAHW,MAAM,GACJ,QAAQ,OAAO,CAAC,CAI5B;AAED;;;;GAIG;AACH,gGAHW,MAAM,GACJ,QAAQ,OAAO,CAAC,CAI5B;AAED;;;;GAIG;AACH,wFAHW,MAAM,GACJ,QAAQ,MAAM,CAAC,CAU3B;AAED;;;;GAIG;AACH,4FAHW,MAAM,GACJ,QAAQ,OAAO,eAAe,EAAE,QAAQ,CAAC,CAUrD;AAED;;;;GAIG;AACH,wFAHW,MAAM,GACJ,QAAQ,OAAO,eAAe,EAAE,IAAI,CAAC,CAUjD;AAED;;;;GAIG;AACH,+FAHW,OAAO,uBAAuB,EAAE,qBAAqB,GACnD,QAAQ,IAAI,CAAC,CAQzB;AAED;;;;;GAKG;AACH,6FAJW,MAAM,GAAC,MAAM,EAAE,aACf,MAAM,GACJ,QAAQ,IAAI,CAAC,CAYzB;AAED;;;;GAIG;AACH,wFAHW,MAAM,GACJ,QAAQ,MAAM,CAAC,CAU3B;AAED;;;;GAIG;AACH,oFAHW,MAAM,GACJ,QAAQ,IAAI,CAAC,CAQzB;AAED;;;;GAIG;AACH,mGAHW,MAAM,GACJ,QAAQ,MAAM,CAAC,CAU3B;AAED;;;;GAIG;AACH,sFAHW,MAAM,GACJ,QAAQ,IAAI,CAAC,CAUzB;AAED;;;;GAIG;AACH,+FAHW,MAAM,GACJ,QAAQ,OAAO,eAAe,EAAE,IAAI,CAAC,CA4BjD;AAED;;;;;;GAMG;AACH,qGAJW,OAAO,SAAS,EAAE,mBAAmB,GAEnC,QAAQ,IAAI,CAAC,CAYzB;wCAeY,OAAO,WAAW,EAAE,yBAAyB"}
|
|
@@ -1,15 +1,184 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
// @ts-check
|
|
3
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
4
|
};
|
|
6
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.mobileReplaceElementValue = exports.getElementRect = exports.clear = exports.getElementScreenshot = exports.click = exports.getText = exports.setValueImmediate = exports.doSetElementValue = exports.getSize = exports.getLocation = exports.getName = exports.elementSelected = exports.elementEnabled = exports.elementDisplayed = exports.getAttribute = exports.active = void 0;
|
|
7
7
|
const bluebird_1 = __importDefault(require("bluebird"));
|
|
8
8
|
const lodash_1 = __importDefault(require("lodash"));
|
|
9
|
-
const support_1 = require("appium/support");
|
|
10
9
|
const driver_1 = require("appium/driver");
|
|
11
|
-
const
|
|
12
|
-
|
|
10
|
+
const appium_android_driver_1 = require("appium-android-driver");
|
|
11
|
+
/**
|
|
12
|
+
* @this {AndroidUiautomator2Driver}
|
|
13
|
+
* @returns {Promise<import('@appium/types').Element>}
|
|
14
|
+
*/
|
|
15
|
+
async function active() {
|
|
16
|
+
return /** @type {import('@appium/types').Element} */ (await this.uiautomator2.jwproxy.command('/element/active', 'GET'));
|
|
17
|
+
}
|
|
18
|
+
exports.active = active;
|
|
19
|
+
/**
|
|
20
|
+
* @this {AndroidUiautomator2Driver}
|
|
21
|
+
* @param {string} attribute
|
|
22
|
+
* @param {string} elementId
|
|
23
|
+
* @returns {Promise<string?>}
|
|
24
|
+
*/
|
|
25
|
+
async function getAttribute(attribute, elementId) {
|
|
26
|
+
return String(await this.uiautomator2.jwproxy.command(`/element/${elementId}/attribute/${attribute}`, 'GET', {}));
|
|
27
|
+
}
|
|
28
|
+
exports.getAttribute = getAttribute;
|
|
29
|
+
/**
|
|
30
|
+
* @this {AndroidUiautomator2Driver}
|
|
31
|
+
* @param {string} elementId
|
|
32
|
+
* @returns {Promise<boolean>}
|
|
33
|
+
*/
|
|
34
|
+
async function elementDisplayed(elementId) {
|
|
35
|
+
return toBool(await this.getAttribute('displayed', elementId));
|
|
36
|
+
}
|
|
37
|
+
exports.elementDisplayed = elementDisplayed;
|
|
38
|
+
/**
|
|
39
|
+
* @this {AndroidUiautomator2Driver}
|
|
40
|
+
* @param {string} elementId
|
|
41
|
+
* @returns {Promise<boolean>}
|
|
42
|
+
*/
|
|
43
|
+
async function elementEnabled(elementId) {
|
|
44
|
+
return toBool(await this.getAttribute('enabled', elementId));
|
|
45
|
+
}
|
|
46
|
+
exports.elementEnabled = elementEnabled;
|
|
47
|
+
/**
|
|
48
|
+
* @this {AndroidUiautomator2Driver}
|
|
49
|
+
* @param {string} elementId
|
|
50
|
+
* @returns {Promise<boolean>}
|
|
51
|
+
*/
|
|
52
|
+
async function elementSelected(elementId) {
|
|
53
|
+
return toBool(await this.getAttribute('selected', elementId));
|
|
54
|
+
}
|
|
55
|
+
exports.elementSelected = elementSelected;
|
|
56
|
+
/**
|
|
57
|
+
* @this {AndroidUiautomator2Driver}
|
|
58
|
+
* @param {string} elementId
|
|
59
|
+
* @returns {Promise<string>}
|
|
60
|
+
*/
|
|
61
|
+
async function getName(elementId) {
|
|
62
|
+
return /** @type {string} */ (await this.uiautomator2.jwproxy.command(`/element/${elementId}/name`, 'GET', {}));
|
|
63
|
+
}
|
|
64
|
+
exports.getName = getName;
|
|
65
|
+
/**
|
|
66
|
+
* @this {AndroidUiautomator2Driver}
|
|
67
|
+
* @param {string} elementId
|
|
68
|
+
* @returns {Promise<import('@appium/types').Position>}
|
|
69
|
+
*/
|
|
70
|
+
async function getLocation(elementId) {
|
|
71
|
+
return /** @type {import('@appium/types').Position} */ (await this.uiautomator2.jwproxy.command(`/element/${elementId}/location`, 'GET', {}));
|
|
72
|
+
}
|
|
73
|
+
exports.getLocation = getLocation;
|
|
74
|
+
/**
|
|
75
|
+
* @this {AndroidUiautomator2Driver}
|
|
76
|
+
* @param {string} elementId
|
|
77
|
+
* @returns {Promise<import('@appium/types').Size>}
|
|
78
|
+
*/
|
|
79
|
+
async function getSize(elementId) {
|
|
80
|
+
return /** @type {import('@appium/types').Size} */ (await this.uiautomator2.jwproxy.command(`/element/${elementId}/size`, 'GET', {}));
|
|
81
|
+
}
|
|
82
|
+
exports.getSize = getSize;
|
|
83
|
+
/**
|
|
84
|
+
* @this {AndroidUiautomator2Driver}
|
|
85
|
+
* @param {import('appium-android-driver').DoSetElementValueOpts} params
|
|
86
|
+
* @returns {Promise<void>}
|
|
87
|
+
*/
|
|
88
|
+
async function doSetElementValue(params) {
|
|
89
|
+
await this.uiautomator2.jwproxy.command(`/element/${params.elementId}/value`, 'POST', params);
|
|
90
|
+
}
|
|
91
|
+
exports.doSetElementValue = doSetElementValue;
|
|
92
|
+
/**
|
|
93
|
+
* @this {AndroidUiautomator2Driver}
|
|
94
|
+
* @param {string|string[]} keys
|
|
95
|
+
* @param {string} elementId
|
|
96
|
+
* @returns {Promise<void>}
|
|
97
|
+
*/
|
|
98
|
+
async function setValueImmediate(keys, elementId) {
|
|
99
|
+
await this.uiautomator2.jwproxy.command(`/element/${elementId}/value`, 'POST', {
|
|
100
|
+
elementId,
|
|
101
|
+
text: lodash_1.default.isArray(keys) ? keys.join('') : keys,
|
|
102
|
+
replace: false,
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
exports.setValueImmediate = setValueImmediate;
|
|
106
|
+
/**
|
|
107
|
+
* @this {AndroidUiautomator2Driver}
|
|
108
|
+
* @param {string} elementId
|
|
109
|
+
* @returns {Promise<string>}
|
|
110
|
+
*/
|
|
111
|
+
async function getText(elementId) {
|
|
112
|
+
return String(await this.uiautomator2.jwproxy.command(`/element/${elementId}/text`, 'GET', {}));
|
|
113
|
+
}
|
|
114
|
+
exports.getText = getText;
|
|
115
|
+
/**
|
|
116
|
+
* @this {AndroidUiautomator2Driver}
|
|
117
|
+
* @param {string} element
|
|
118
|
+
* @returns {Promise<void>}
|
|
119
|
+
*/
|
|
120
|
+
async function click(element) {
|
|
121
|
+
await this.uiautomator2.jwproxy.command(`/element/${element}/click`, 'POST', { element });
|
|
122
|
+
}
|
|
123
|
+
exports.click = click;
|
|
124
|
+
/**
|
|
125
|
+
* @this {AndroidUiautomator2Driver}
|
|
126
|
+
* @param {string} element
|
|
127
|
+
* @returns {Promise<string>}
|
|
128
|
+
*/
|
|
129
|
+
async function getElementScreenshot(element) {
|
|
130
|
+
return String(await this.uiautomator2.jwproxy.command(`/element/${element}/screenshot`, 'GET', {}));
|
|
131
|
+
}
|
|
132
|
+
exports.getElementScreenshot = getElementScreenshot;
|
|
133
|
+
/**
|
|
134
|
+
* @this {AndroidUiautomator2Driver}
|
|
135
|
+
* @param {string} elementId
|
|
136
|
+
* @returns {Promise<void>}
|
|
137
|
+
*/
|
|
138
|
+
async function clear(elementId) {
|
|
139
|
+
await this.uiautomator2.jwproxy.command(`/element/${elementId}/clear`, 'POST', {
|
|
140
|
+
elementId,
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
exports.clear = clear;
|
|
144
|
+
/**
|
|
145
|
+
* @this {AndroidUiautomator2Driver}
|
|
146
|
+
* @param {string} elementId
|
|
147
|
+
* @returns {Promise<import('@appium/types').Rect>}
|
|
148
|
+
*/
|
|
149
|
+
async function getElementRect(elementId) {
|
|
150
|
+
const chromedriver = /** @type {import('appium-chromedriver').default} */ (this.chromedriver);
|
|
151
|
+
if (this.isWebContext()) {
|
|
152
|
+
this.log.debug(`Detected downstream chromedriver protocol: ${chromedriver.jwproxy.downstreamProtocol}`);
|
|
153
|
+
if (chromedriver.jwproxy.downstreamProtocol === driver_1.PROTOCOLS.MJSONWP) {
|
|
154
|
+
const [{ x, y }, { width, height }] =
|
|
155
|
+
/** @type {[import('@appium/types').Position, import('@appium/types').Size]} */ (await bluebird_1.default.all([
|
|
156
|
+
chromedriver.jwproxy.command(`/element/${elementId}/location`, 'GET'),
|
|
157
|
+
chromedriver.jwproxy.command(`/element/${elementId}/size`, 'GET'),
|
|
158
|
+
]));
|
|
159
|
+
return { x, y, width, height };
|
|
160
|
+
}
|
|
161
|
+
return /** @type {import('@appium/types').Rect} */ (await chromedriver.jwproxy.command(`/element/${elementId}/rect`, 'GET'));
|
|
162
|
+
}
|
|
163
|
+
return /** @type {import('@appium/types').Rect} */ (await this.uiautomator2.jwproxy.command(`/element/${elementId}/rect`, 'GET'));
|
|
164
|
+
}
|
|
165
|
+
exports.getElementRect = getElementRect;
|
|
166
|
+
/**
|
|
167
|
+
* Sends text to the given element by replacing its previous content
|
|
168
|
+
* @this {AndroidUiautomator2Driver}
|
|
169
|
+
* @param {import('./types').ReplaceValueOptions} opts
|
|
170
|
+
* @throws {Error} If there was a faulre while setting the text
|
|
171
|
+
* @returns {Promise<void>}
|
|
172
|
+
*/
|
|
173
|
+
async function mobileReplaceElementValue(opts) {
|
|
174
|
+
const { elementId, text } = appium_android_driver_1.utils.requireArgs(['elementId', 'text'], opts);
|
|
175
|
+
await this.uiautomator2.jwproxy.command(`/element/${elementId}/value`, 'POST', {
|
|
176
|
+
text,
|
|
177
|
+
replace: true,
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
exports.mobileReplaceElementValue = mobileReplaceElementValue;
|
|
181
|
+
// #region Internal Helpers
|
|
13
182
|
/**
|
|
14
183
|
* @param {any} s
|
|
15
184
|
* @returns {boolean}
|
|
@@ -17,127 +186,8 @@ const mixins_1 = require("./mixins");
|
|
|
17
186
|
function toBool(s) {
|
|
18
187
|
return lodash_1.default.isString(s) ? s.toLowerCase() === 'true' : !!s;
|
|
19
188
|
}
|
|
189
|
+
// #endregion
|
|
20
190
|
/**
|
|
21
|
-
* @
|
|
22
|
-
* @satisfies {import('@appium/types').ExternalDriver}
|
|
23
|
-
*/
|
|
24
|
-
const ElementMixin = {
|
|
25
|
-
async active() {
|
|
26
|
-
return /** @type {import('@appium/types').Element} */ (await this.uiautomator2.jwproxy.command('/element/active', 'GET'));
|
|
27
|
-
},
|
|
28
|
-
async getAttribute(attribute, elementId) {
|
|
29
|
-
return String(await this.uiautomator2.jwproxy.command(`/element/${elementId}/attribute/${attribute}`, 'GET', {}));
|
|
30
|
-
},
|
|
31
|
-
async elementDisplayed(elementId) {
|
|
32
|
-
return toBool(await this.getAttribute('displayed', elementId));
|
|
33
|
-
},
|
|
34
|
-
async elementEnabled(elementId) {
|
|
35
|
-
return toBool(await this.getAttribute('enabled', elementId));
|
|
36
|
-
},
|
|
37
|
-
async elementSelected(elementId) {
|
|
38
|
-
return toBool(await this.getAttribute('selected', elementId));
|
|
39
|
-
},
|
|
40
|
-
async getName(elementId) {
|
|
41
|
-
return /** @type {string} */ (await this.uiautomator2.jwproxy.command(`/element/${elementId}/name`, 'GET', {}));
|
|
42
|
-
},
|
|
43
|
-
async getLocation(elementId) {
|
|
44
|
-
return /** @type {import('@appium/types').Position} */ (await this.uiautomator2.jwproxy.command(`/element/${elementId}/location`, 'GET', {}));
|
|
45
|
-
},
|
|
46
|
-
async getSize(elementId) {
|
|
47
|
-
return /** @type {import('@appium/types').Size} */ (await this.uiautomator2.jwproxy.command(`/element/${elementId}/size`, 'GET', {}));
|
|
48
|
-
},
|
|
49
|
-
async touchLongClick(element, x, y, duration) {
|
|
50
|
-
let params = { element, x, y, duration };
|
|
51
|
-
await this.uiautomator2.jwproxy.command(`/touch/longclick`, 'POST', { params });
|
|
52
|
-
},
|
|
53
|
-
async touchDown(element, x, y) {
|
|
54
|
-
let params = { element, x, y };
|
|
55
|
-
await this.uiautomator2.jwproxy.command(`/touch/down`, 'POST', { params });
|
|
56
|
-
},
|
|
57
|
-
async touchUp(element, x, y) {
|
|
58
|
-
let params = { element, x, y };
|
|
59
|
-
await this.uiautomator2.jwproxy.command(`/touch/up`, 'POST', { params });
|
|
60
|
-
},
|
|
61
|
-
async touchMove(element, x, y) {
|
|
62
|
-
let params = { element, x, y };
|
|
63
|
-
await this.uiautomator2.jwproxy.command(`/touch/move`, 'POST', { params });
|
|
64
|
-
},
|
|
65
|
-
async doSetElementValue(params) {
|
|
66
|
-
await this.uiautomator2.jwproxy.command(`/element/${params.elementId}/value`, 'POST', params);
|
|
67
|
-
},
|
|
68
|
-
async setValueImmediate(keys, elementId) {
|
|
69
|
-
await this.uiautomator2.jwproxy.command(`/element/${elementId}/value`, 'POST', {
|
|
70
|
-
elementId,
|
|
71
|
-
text: lodash_1.default.isArray(keys) ? keys.join('') : keys,
|
|
72
|
-
replace: false,
|
|
73
|
-
});
|
|
74
|
-
},
|
|
75
|
-
async getText(elementId) {
|
|
76
|
-
return String(await this.uiautomator2.jwproxy.command(`/element/${elementId}/text`, 'GET', {}));
|
|
77
|
-
},
|
|
78
|
-
async click(element) {
|
|
79
|
-
await this.uiautomator2.jwproxy.command(`/element/${element}/click`, 'POST', { element });
|
|
80
|
-
},
|
|
81
|
-
async getElementScreenshot(element) {
|
|
82
|
-
return String(await this.uiautomator2.jwproxy.command(`/element/${element}/screenshot`, 'GET', {}));
|
|
83
|
-
},
|
|
84
|
-
async tap(elementId = null, x = null, y = null, count = 1) {
|
|
85
|
-
const areCoordinatesDefined = support_1.util.hasValue(x) && support_1.util.hasValue(y);
|
|
86
|
-
if (!support_1.util.hasValue(elementId) && !areCoordinatesDefined) {
|
|
87
|
-
throw new Error(`Either element id to tap or both absolute coordinates should be defined`);
|
|
88
|
-
}
|
|
89
|
-
for (let i = 0; i < count; i++) {
|
|
90
|
-
if (support_1.util.hasValue(elementId) && !areCoordinatesDefined) {
|
|
91
|
-
// we are either tapping on the default location of the element
|
|
92
|
-
// or an offset from the top left corner
|
|
93
|
-
await this.uiautomator2.jwproxy.command(`/element/${elementId}/click`, 'POST');
|
|
94
|
-
}
|
|
95
|
-
else {
|
|
96
|
-
await this.uiautomator2.jwproxy.command(`/appium/tap`, 'POST', {
|
|
97
|
-
x,
|
|
98
|
-
y,
|
|
99
|
-
[driver_1.W3C_ELEMENT_KEY]: elementId,
|
|
100
|
-
});
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
},
|
|
104
|
-
async clear(elementId) {
|
|
105
|
-
await this.uiautomator2.jwproxy.command(`/element/${elementId}/clear`, 'POST', {
|
|
106
|
-
elementId,
|
|
107
|
-
});
|
|
108
|
-
},
|
|
109
|
-
async getElementRect(elementId) {
|
|
110
|
-
const chromedriver = /** @type {import('appium-chromedriver').default} */ (this.chromedriver);
|
|
111
|
-
if (this.isWebContext()) {
|
|
112
|
-
this.log.debug(`Detected downstream chromedriver protocol: ${chromedriver.jwproxy.downstreamProtocol}`);
|
|
113
|
-
if (chromedriver.jwproxy.downstreamProtocol === driver_1.PROTOCOLS.MJSONWP) {
|
|
114
|
-
const [{ x, y }, { width, height }] =
|
|
115
|
-
/** @type {[import('@appium/types').Position, import('@appium/types').Size]} */ (await bluebird_1.default.all([
|
|
116
|
-
chromedriver.jwproxy.command(`/element/${elementId}/location`, 'GET'),
|
|
117
|
-
chromedriver.jwproxy.command(`/element/${elementId}/size`, 'GET'),
|
|
118
|
-
]));
|
|
119
|
-
return { x, y, width, height };
|
|
120
|
-
}
|
|
121
|
-
return /** @type {import('@appium/types').Rect} */ (await chromedriver.jwproxy.command(`/element/${elementId}/rect`, 'GET'));
|
|
122
|
-
}
|
|
123
|
-
return /** @type {import('@appium/types').Rect} */ (await this.uiautomator2.jwproxy.command(`/element/${elementId}/rect`, 'GET'));
|
|
124
|
-
},
|
|
125
|
-
/**
|
|
126
|
-
* Sends text to the given element by replacing its previous content
|
|
127
|
-
*
|
|
128
|
-
* @param {import('./types').ReplaceValueOptions} opts
|
|
129
|
-
* @throws {Error} If there was a faulre while setting the text
|
|
130
|
-
*/
|
|
131
|
-
async mobileReplaceElementValue(opts) {
|
|
132
|
-
const { elementId, text } = (0, utils_1.requireArgs)(['elementId', 'text'], opts);
|
|
133
|
-
await this.uiautomator2.jwproxy.command(`/element/${elementId}/value`, 'POST', {
|
|
134
|
-
text,
|
|
135
|
-
replace: true,
|
|
136
|
-
});
|
|
137
|
-
},
|
|
138
|
-
};
|
|
139
|
-
(0, mixins_1.mixin)(ElementMixin);
|
|
140
|
-
/**
|
|
141
|
-
* @typedef {import('../uiautomator2').UiAutomator2Server} UiAutomator2Server
|
|
191
|
+
* @typedef {import('../driver').AndroidUiautomator2Driver} AndroidUiautomator2Driver
|
|
142
192
|
*/
|
|
143
193
|
//# sourceMappingURL=element.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"element.js","sourceRoot":"","sources":["../../../lib/commands/element.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"element.js","sourceRoot":"","sources":["../../../lib/commands/element.js"],"names":[],"mappings":";;;;;;AAAA,wDAAyB;AACzB,oDAAuB;AACvB,0CAAwC;AACxC,iEAA4C;AAE5C;;;GAGG;AACI,KAAK,UAAU,MAAM;IAC1B,OAAO,8CAA8C,CAAC,CACpD,MAAM,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,OAAO,CACrC,iBAAiB,EACjB,KAAK,CACN,CACF,CAAC;AACJ,CAAC;AAPD,wBAOC;AAED;;;;;GAKG;AACI,KAAK,UAAU,YAAY,CAAC,SAAS,EAAE,SAAS;IACrD,OAAO,MAAM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ACN,CACF,CAAC;AACJ,CAAC;AA1BD,wCA0BC;AAED;;;;;;GAMG;AACI,KAAK,UAAU,yBAAyB,CAAC,IAAI;IAClD,MAAM,EAAC,SAAS,EAAE,IAAI,EAAC,GAAG,6BAAK,CAAC,WAAW,CAAC,CAAC,WAAW,EAAE,MAAM,CAAC,EAAE,IAAI,CAAC,CAAC;IACzE,MAAM,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,OAAO,CACrC,YAAY,SAAS,QAAQ,EAC7B,MAAM,EACN;QACE,IAAI;QACJ,OAAO,EAAE,IAAI;KACd,CACF,CAAC;AACJ,CAAC;AAVD,8DAUC;AAED,2BAA2B;AAE3B;;;GAGG;AACH,SAAS,MAAM,CAAC,CAAC;IACf,OAAO,gBAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,KAAK,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAC1D,CAAC;AAED,aAAa;AAEb;;GAEG"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @override
|
|
3
|
+
* @privateRemarks Because the "mobile" commands (execute methods) in this
|
|
4
|
+
* driver universally accept an options object, this method will _not_ call
|
|
5
|
+
* into `BaseDriver.executeMethod`.
|
|
6
|
+
* @this {AndroidUiautomator2Driver}
|
|
7
|
+
* @param {string} script
|
|
8
|
+
* @param {any[]} [args]
|
|
9
|
+
* @returns {Promise<any>}
|
|
10
|
+
*/
|
|
11
|
+
export function execute(this: AndroidUiautomator2Driver, script: string, args?: any[] | undefined): Promise<any>;
|
|
12
|
+
/**
|
|
13
|
+
* @override
|
|
14
|
+
* @this {AndroidUiautomator2Driver}
|
|
15
|
+
* @param {string} script Must be of the form `mobile: <something>`, which
|
|
16
|
+
* differs from its parent class implementation.
|
|
17
|
+
* @param {import('@appium/types').StringRecord} [opts={}]
|
|
18
|
+
* @returns {Promise<any>}
|
|
19
|
+
*/
|
|
20
|
+
export function executeMobile(this: AndroidUiautomator2Driver, script: string, opts?: import("@appium/types").StringRecord<any> | undefined): Promise<any>;
|
|
21
|
+
export type UiAutomator2Server = import('../uiautomator2').UiAutomator2Server;
|
|
22
|
+
export type ADB = import('appium-adb').ADB;
|
|
23
|
+
export type StringRecord<T = any> = import('@appium/types').StringRecord<T>;
|
|
24
|
+
import { AndroidUiautomator2Driver } from '../driver';
|
|
25
|
+
//# sourceMappingURL=execute.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"execute.d.ts","sourceRoot":"","sources":["../../../lib/commands/execute.js"],"names":[],"mappings":"AAMA;;;;;;;;;GASG;AACH,iEAJW,MAAM,6BAEJ,QAAQ,GAAG,CAAC,CAyBxB;AAED;;;;;;;GAOG;AACH,uEALW,MAAM,iEAGJ,QAAQ,GAAG,CAAC,CAmBxB;iCA8CY,OAAO,iBAAiB,EAAE,kBAAkB;kBAC5C,OAAO,YAAY,EAAE,GAAG;oCAKxB,OAAO,eAAe,EAAE,YAAY,CAAC,CAAC,CAAC;0CApHZ,WAAW"}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.executeMobile = exports.execute = void 0;
|
|
7
|
+
const lodash_1 = __importDefault(require("lodash"));
|
|
8
|
+
const driver_1 = require("appium/driver");
|
|
9
|
+
const driver_2 = require("../driver");
|
|
10
|
+
const MOBILE_SCRIPT_NAME_PREFIX = 'mobile:';
|
|
11
|
+
/**
|
|
12
|
+
* @override
|
|
13
|
+
* @privateRemarks Because the "mobile" commands (execute methods) in this
|
|
14
|
+
* driver universally accept an options object, this method will _not_ call
|
|
15
|
+
* into `BaseDriver.executeMethod`.
|
|
16
|
+
* @this {AndroidUiautomator2Driver}
|
|
17
|
+
* @param {string} script
|
|
18
|
+
* @param {any[]} [args]
|
|
19
|
+
* @returns {Promise<any>}
|
|
20
|
+
*/
|
|
21
|
+
async function execute(script, args) {
|
|
22
|
+
const mobileScriptName = toExecuteMethodName(script);
|
|
23
|
+
const isWebContext = this.isWebContext();
|
|
24
|
+
if (mobileScriptName && isWebContext || !isWebContext) {
|
|
25
|
+
if (mobileScriptName) {
|
|
26
|
+
const executeMethodArgs = preprocessExecuteMethodArgs(args);
|
|
27
|
+
this.log.info(`Executing method '${mobileScriptName}'`);
|
|
28
|
+
return await this.executeMobile(mobileScriptName, executeMethodArgs);
|
|
29
|
+
}
|
|
30
|
+
// Just pass the script name through and let it fail with a proper error message
|
|
31
|
+
return await this.executeMobile(`${script}`, {});
|
|
32
|
+
}
|
|
33
|
+
const endpoint =
|
|
34
|
+
/** @type {import('appium-chromedriver').Chromedriver} */ (this.chromedriver).jwproxy
|
|
35
|
+
.downstreamProtocol === driver_1.PROTOCOLS.MJSONWP
|
|
36
|
+
? '/execute'
|
|
37
|
+
: '/execute/sync';
|
|
38
|
+
return await /** @type {import('appium-chromedriver').Chromedriver} */ (this.chromedriver).jwproxy.command(endpoint, 'POST', {
|
|
39
|
+
script,
|
|
40
|
+
args,
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
exports.execute = execute;
|
|
44
|
+
/**
|
|
45
|
+
* @override
|
|
46
|
+
* @this {AndroidUiautomator2Driver}
|
|
47
|
+
* @param {string} script Must be of the form `mobile: <something>`, which
|
|
48
|
+
* differs from its parent class implementation.
|
|
49
|
+
* @param {import('@appium/types').StringRecord} [opts={}]
|
|
50
|
+
* @returns {Promise<any>}
|
|
51
|
+
*/
|
|
52
|
+
async function executeMobile(script, opts = {}) {
|
|
53
|
+
if (!(script in driver_2.AndroidUiautomator2Driver.executeMethodMap)) {
|
|
54
|
+
const commandNames = lodash_1.default.map(lodash_1.default.keys(driver_2.AndroidUiautomator2Driver.executeMethodMap), (value) => value.slice(8));
|
|
55
|
+
throw new driver_1.errors.UnknownCommandError(`Unknown mobile command "${script}". ` +
|
|
56
|
+
`Only ${commandNames.join(', ')} commands are supported.`);
|
|
57
|
+
}
|
|
58
|
+
const methodName = driver_2.AndroidUiautomator2Driver.executeMethodMap[
|
|
59
|
+
/** @type {keyof import('../execute-method-map').Uiautomator2ExecuteMethodMap} */ (script)].command;
|
|
60
|
+
return await /** @type {(opts?: any) => Promise<unknown>} */ (this[methodName])(opts);
|
|
61
|
+
}
|
|
62
|
+
exports.executeMobile = executeMobile;
|
|
63
|
+
// #region Internal Helpers
|
|
64
|
+
/**
|
|
65
|
+
* Messages the arguments going into an execute method.
|
|
66
|
+
* @remarks A similar method is implemented in `appium-xcuitest-driver`, but it
|
|
67
|
+
* appears the methods in here handle unwrapping of `Element` objects, so we do
|
|
68
|
+
* not do that here.
|
|
69
|
+
* @param {readonly any[] | readonly [StringRecord] | Readonly<StringRecord>} [args]
|
|
70
|
+
* @internal
|
|
71
|
+
* @returns {StringRecord<unknown>}
|
|
72
|
+
*/
|
|
73
|
+
function preprocessExecuteMethodArgs(args) {
|
|
74
|
+
if (lodash_1.default.isArray(args)) {
|
|
75
|
+
args = lodash_1.default.first(args);
|
|
76
|
+
}
|
|
77
|
+
const executeMethodArgs = /** @type {StringRecord<unknown>} */ (args ?? {});
|
|
78
|
+
/**
|
|
79
|
+
* Renames the deprecated `element` key to `elementId`. Historically,
|
|
80
|
+
* all of the pre-Execute-Method-Map execute methods accepted an `element` _or_ and `elementId` param.
|
|
81
|
+
* This assigns the `element` value to `elementId` if `elementId` is not already present.
|
|
82
|
+
*/
|
|
83
|
+
if (!('elementId' in executeMethodArgs) && 'element' in executeMethodArgs) {
|
|
84
|
+
executeMethodArgs.elementId = executeMethodArgs.element;
|
|
85
|
+
delete executeMethodArgs.element;
|
|
86
|
+
}
|
|
87
|
+
return executeMethodArgs;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Type guard to check if a script is an execute method.
|
|
91
|
+
* @param {any} script
|
|
92
|
+
* @internal
|
|
93
|
+
* @returns {string?}
|
|
94
|
+
*/
|
|
95
|
+
function toExecuteMethodName(script) {
|
|
96
|
+
return lodash_1.default.startsWith(script, MOBILE_SCRIPT_NAME_PREFIX)
|
|
97
|
+
? script.replace(new RegExp(`${MOBILE_SCRIPT_NAME_PREFIX}\\s*`), `${MOBILE_SCRIPT_NAME_PREFIX} `)
|
|
98
|
+
: null;
|
|
99
|
+
}
|
|
100
|
+
// #endregion
|
|
101
|
+
/**
|
|
102
|
+
* @typedef {import('../uiautomator2').UiAutomator2Server} UiAutomator2Server
|
|
103
|
+
* @typedef {import('appium-adb').ADB} ADB
|
|
104
|
+
*/
|
|
105
|
+
/**
|
|
106
|
+
* @template [T=any]
|
|
107
|
+
* @typedef {import('@appium/types').StringRecord<T>} StringRecord
|
|
108
|
+
*/
|
|
109
|
+
//# sourceMappingURL=execute.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"execute.js","sourceRoot":"","sources":["../../../lib/commands/execute.js"],"names":[],"mappings":";;;;;;AAAA,oDAAuB;AACvB,0CAAgD;AAChD,sCAAoD;AAEpD,MAAM,yBAAyB,GAAG,SAAS,CAAC;AAE5C;;;;;;;;;GASG;AACI,KAAK,UAAU,OAAO,CAAC,MAAM,EAAE,IAAI;IACxC,MAAM,gBAAgB,GAAG,mBAAmB,CAAC,MAAM,CAAC,CAAC;IACrD,MAAM,YAAY,GAAG,IAAI,CAAC,YAAY,EAAE,CAAC;IACzC,IAAI,gBAAgB,IAAI,YAAY,IAAI,CAAC,YAAY,EAAE;QACrD,IAAI,gBAAgB,EAAE;YACpB,MAAM,iBAAiB,GAAG,2BAA2B,CAAC,IAAI,CAAC,CAAC;YAC5D,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,qBAAqB,gBAAgB,GAAG,CAAC,CAAC;YACxD,OAAO,MAAM,IAAI,CAAC,aAAa,CAAC,gBAAgB,EAAE,iBAAiB,CAAC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A2B,CAAC,IAAI;IACvC,IAAI,gBAAC,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;QACnB,IAAI,GAAG,gBAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;KACtB;IACD,MAAM,iBAAiB,GAAG,oCAAoC,CAAC,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC;IAC5E;;;;OAIG;IACH,IAAI,CAAC,CAAC,WAAW,IAAI,iBAAiB,CAAC,IAAI,SAAS,IAAI,iBAAiB,EAAE;QACzE,iBAAiB,CAAC,SAAS,GAAG,iBAAiB,CAAC,OAAO,CAAC;QACxD,OAAO,iBAAiB,CAAC,OAAO,CAAC;KAClC;IAED,OAAO,iBAAiB,CAAC;AAC3B,CAAC;AAED;;;;;GAKG;AACH,SAAS,mBAAmB,CAAC,MAAM;IACjC,OAAO,gBAAC,CAAC,UAAU,CAAC,MAAM,EAAE,yBAAyB,CAAC;QACpD,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,MAAM,CAAC,GAAG,yBAAyB,MAAM,CAAC,EAAE,GAAG,yBAAyB,GAAG,CAAC;QACjG,CAAC,CAAC,IAAI,CAAC;AACX,CAAC;AAED,aAAa;AAEb;;;GAGG;AAEH;;;GAGG"}
|
|
@@ -1,2 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @privateRemarks Overriding helpers.doFindElementOrEls functionality of appium-android-driver,
|
|
3
|
+
* this.element initialized in find.js of appium-android-drive.
|
|
4
|
+
*
|
|
5
|
+
* @this {AndroidUiautomator2Driver}
|
|
6
|
+
* @param {import('appium-android-driver').FindElementOpts} params
|
|
7
|
+
* @returns {Promise<Element | Element[]>}
|
|
8
|
+
*/
|
|
9
|
+
export function doFindElementOrEls(this: import("../driver").AndroidUiautomator2Driver, params: import('appium-android-driver').FindElementOpts): Promise<Element | Element[]>;
|
|
1
10
|
export type Element = import('@appium/types').Element;
|
|
11
|
+
export type AndroidUiautomator2Driver = import('../driver').AndroidUiautomator2Driver;
|
|
2
12
|
//# sourceMappingURL=find.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"find.d.ts","sourceRoot":"","sources":["../../../lib/commands/find.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"find.d.ts","sourceRoot":"","sources":["../../../lib/commands/find.js"],"names":[],"mappings":"AASA;;;;;;;GAOG;AACH,gGAHW,OAAO,uBAAuB,EAAE,eAAe,GAC7C,QAAQ,OAAO,GAAG,OAAO,EAAE,CAAC,CA0BxC;sBAGY,OAAO,eAAe,EAAE,OAAO;wCAC/B,OAAO,WAAW,EAAE,yBAAyB"}
|