appium-uiautomator2-driver 6.7.5 → 6.7.7
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 +12 -0
- package/build/lib/commands/actions.d.ts +26 -29
- package/build/lib/commands/actions.d.ts.map +1 -1
- package/build/lib/commands/actions.js +19 -27
- package/build/lib/commands/actions.js.map +1 -1
- package/build/lib/commands/alert.d.ts +14 -22
- package/build/lib/commands/alert.d.ts.map +1 -1
- package/build/lib/commands/alert.js +8 -19
- package/build/lib/commands/alert.js.map +1 -1
- package/build/lib/commands/app-management.d.ts +7 -10
- package/build/lib/commands/app-management.d.ts.map +1 -1
- package/build/lib/commands/app-management.js +4 -14
- package/build/lib/commands/app-management.js.map +1 -1
- package/build/lib/commands/battery.d.ts +4 -5
- package/build/lib/commands/battery.d.ts.map +1 -1
- package/build/lib/commands/battery.js +4 -9
- package/build/lib/commands/battery.js.map +1 -1
- package/build/lib/commands/clipboard.d.ts +9 -13
- package/build/lib/commands/clipboard.d.ts.map +1 -1
- package/build/lib/commands/clipboard.js +7 -14
- package/build/lib/commands/clipboard.js.map +1 -1
- package/build/lib/commands/element.d.ts +64 -69
- package/build/lib/commands/element.d.ts.map +1 -1
- package/build/lib/commands/element.js +64 -84
- package/build/lib/commands/element.js.map +1 -1
- package/build/lib/commands/find.d.ts +13 -9
- package/build/lib/commands/find.d.ts.map +1 -1
- package/build/lib/commands/find.js +4 -16
- package/build/lib/commands/find.js.map +1 -1
- package/build/lib/commands/gestures.d.ts +87 -189
- package/build/lib/commands/gestures.d.ts.map +1 -1
- package/build/lib/commands/gestures.js +77 -204
- package/build/lib/commands/gestures.js.map +1 -1
- package/build/lib/commands/keyboard.d.ts +30 -41
- package/build/lib/commands/keyboard.d.ts.map +1 -1
- package/build/lib/commands/keyboard.js +22 -37
- package/build/lib/commands/keyboard.js.map +1 -1
- package/build/lib/commands/misc.d.ts +19 -35
- package/build/lib/commands/misc.d.ts.map +1 -1
- package/build/lib/commands/misc.js +15 -30
- package/build/lib/commands/misc.js.map +1 -1
- package/build/lib/commands/navigation.d.ts +11 -16
- package/build/lib/commands/navigation.d.ts.map +1 -1
- package/build/lib/commands/navigation.js +9 -17
- package/build/lib/commands/navigation.js.map +1 -1
- package/build/lib/commands/viewport.d.ts +23 -22
- package/build/lib/commands/viewport.d.ts.map +1 -1
- package/build/lib/commands/viewport.js +17 -24
- package/build/lib/commands/viewport.js.map +1 -1
- package/build/tsconfig.tsbuildinfo +1 -1
- package/lib/commands/actions.ts +95 -0
- package/lib/commands/alert.ts +46 -0
- package/lib/commands/app-management.ts +25 -0
- package/lib/commands/battery.ts +19 -0
- package/lib/commands/clipboard.ts +29 -0
- package/lib/commands/element.ts +180 -0
- package/lib/commands/find.ts +48 -0
- package/lib/commands/gestures.ts +297 -0
- package/lib/commands/keyboard.ts +102 -0
- package/lib/commands/misc.ts +67 -0
- package/lib/commands/navigation.ts +32 -0
- package/lib/commands/viewport.ts +78 -0
- package/npm-shrinkwrap.json +16 -46
- package/package.json +1 -1
- package/lib/commands/actions.js +0 -107
- package/lib/commands/alert.js +0 -63
- package/lib/commands/app-management.js +0 -32
- package/lib/commands/battery.js +0 -23
- package/lib/commands/clipboard.js +0 -37
- package/lib/commands/element.js +0 -261
- package/lib/commands/find.js +0 -47
- package/lib/commands/gestures.js +0 -446
- package/lib/commands/keyboard.js +0 -108
- package/lib/commands/misc.js +0 -109
- package/lib/commands/navigation.js +0 -33
- package/lib/commands/viewport.js +0 -100
|
@@ -1,102 +1,97 @@
|
|
|
1
|
+
import type { DoSetElementValueOpts } from 'appium-android-driver';
|
|
2
|
+
import type { Element as AppiumElement, Position, Rect, Size } from '@appium/types';
|
|
3
|
+
import type { AndroidUiautomator2Driver } from '../driver';
|
|
1
4
|
/**
|
|
2
|
-
*
|
|
3
|
-
* @returns
|
|
5
|
+
* Gets the currently active element.
|
|
6
|
+
* @returns The currently active element.
|
|
4
7
|
*/
|
|
5
|
-
export function active(this:
|
|
8
|
+
export declare function active(this: AndroidUiautomator2Driver): Promise<AppiumElement>;
|
|
6
9
|
/**
|
|
7
|
-
*
|
|
8
|
-
* @param
|
|
9
|
-
* @param
|
|
10
|
-
* @returns
|
|
10
|
+
* Gets an element attribute value.
|
|
11
|
+
* @param attribute - Name of the attribute to retrieve.
|
|
12
|
+
* @param elementId - ID of the element.
|
|
13
|
+
* @returns The attribute value as a string.
|
|
11
14
|
*/
|
|
12
|
-
export function getAttribute(this:
|
|
15
|
+
export declare function getAttribute(this: AndroidUiautomator2Driver, attribute: string, elementId: string): Promise<string>;
|
|
13
16
|
/**
|
|
14
|
-
*
|
|
15
|
-
* @param
|
|
16
|
-
* @returns
|
|
17
|
+
* Returns whether the element is displayed.
|
|
18
|
+
* @param elementId - ID of the element.
|
|
19
|
+
* @returns True if the element is displayed, false otherwise.
|
|
17
20
|
*/
|
|
18
|
-
export function elementDisplayed(this:
|
|
21
|
+
export declare function elementDisplayed(this: AndroidUiautomator2Driver, elementId: string): Promise<boolean>;
|
|
19
22
|
/**
|
|
20
|
-
*
|
|
21
|
-
* @param
|
|
22
|
-
* @returns
|
|
23
|
+
* Returns whether the element is enabled.
|
|
24
|
+
* @param elementId - ID of the element.
|
|
25
|
+
* @returns True if the element is enabled, false otherwise.
|
|
23
26
|
*/
|
|
24
|
-
export function elementEnabled(this:
|
|
27
|
+
export declare function elementEnabled(this: AndroidUiautomator2Driver, elementId: string): Promise<boolean>;
|
|
25
28
|
/**
|
|
26
|
-
*
|
|
27
|
-
* @param
|
|
28
|
-
* @returns
|
|
29
|
+
* Returns whether the element is selected.
|
|
30
|
+
* @param elementId - ID of the element.
|
|
31
|
+
* @returns True if the element is selected, false otherwise.
|
|
29
32
|
*/
|
|
30
|
-
export function elementSelected(this:
|
|
33
|
+
export declare function elementSelected(this: AndroidUiautomator2Driver, elementId: string): Promise<boolean>;
|
|
31
34
|
/**
|
|
32
|
-
*
|
|
33
|
-
* @param
|
|
34
|
-
* @returns
|
|
35
|
+
* Gets the element tag name.
|
|
36
|
+
* @param elementId - ID of the element.
|
|
37
|
+
* @returns The element tag name.
|
|
35
38
|
*/
|
|
36
|
-
export function getName(this:
|
|
39
|
+
export declare function getName(this: AndroidUiautomator2Driver, elementId: string): Promise<string>;
|
|
37
40
|
/**
|
|
38
|
-
*
|
|
39
|
-
* @param
|
|
40
|
-
* @returns
|
|
41
|
+
* Gets the element location.
|
|
42
|
+
* @param elementId - ID of the element.
|
|
43
|
+
* @returns The element position coordinates (x, y).
|
|
41
44
|
*/
|
|
42
|
-
export function getLocation(this:
|
|
45
|
+
export declare function getLocation(this: AndroidUiautomator2Driver, elementId: string): Promise<Position>;
|
|
43
46
|
/**
|
|
44
|
-
*
|
|
45
|
-
* @param
|
|
46
|
-
* @returns
|
|
47
|
+
* Gets the element size.
|
|
48
|
+
* @param elementId - ID of the element.
|
|
49
|
+
* @returns The element size (width, height).
|
|
47
50
|
*/
|
|
48
|
-
export function getSize(this:
|
|
51
|
+
export declare function getSize(this: AndroidUiautomator2Driver, elementId: string): Promise<Size>;
|
|
49
52
|
/**
|
|
50
|
-
*
|
|
51
|
-
* @param
|
|
52
|
-
* @returns {Promise<void>}
|
|
53
|
+
* Sets the value of an element using the upstream driver API.
|
|
54
|
+
* @param params - Options containing the element ID and value to set.
|
|
53
55
|
*/
|
|
54
|
-
export function doSetElementValue(this:
|
|
56
|
+
export declare function doSetElementValue(this: AndroidUiautomator2Driver, params: DoSetElementValueOpts): Promise<void>;
|
|
55
57
|
/**
|
|
56
|
-
*
|
|
57
|
-
* @param
|
|
58
|
-
* @param
|
|
59
|
-
* @returns {Promise<void>}
|
|
58
|
+
* Sends text to an element without replacement.
|
|
59
|
+
* @param keys - Text to send, either as a string or array of strings (which will be joined).
|
|
60
|
+
* @param elementId - ID of the element.
|
|
60
61
|
*/
|
|
61
|
-
export function setValueImmediate(this:
|
|
62
|
+
export declare function setValueImmediate(this: AndroidUiautomator2Driver, keys: string | string[], elementId: string): Promise<void>;
|
|
62
63
|
/**
|
|
63
|
-
*
|
|
64
|
-
* @param
|
|
65
|
-
* @returns
|
|
64
|
+
* Gets the element text.
|
|
65
|
+
* @param elementId - ID of the element.
|
|
66
|
+
* @returns The element text content.
|
|
66
67
|
*/
|
|
67
|
-
export function getText(this:
|
|
68
|
+
export declare function getText(this: AndroidUiautomator2Driver, elementId: string): Promise<string>;
|
|
68
69
|
/**
|
|
69
|
-
*
|
|
70
|
-
* @param
|
|
71
|
-
* @returns {Promise<void>}
|
|
70
|
+
* Clicks the given element.
|
|
71
|
+
* @param element - ID of the element to click.
|
|
72
72
|
*/
|
|
73
|
-
export function click(this:
|
|
73
|
+
export declare function click(this: AndroidUiautomator2Driver, element: string): Promise<void>;
|
|
74
74
|
/**
|
|
75
|
-
*
|
|
76
|
-
* @param
|
|
77
|
-
* @returns
|
|
75
|
+
* Takes a screenshot of the element.
|
|
76
|
+
* @param element - ID of the element.
|
|
77
|
+
* @returns Base64-encoded PNG screenshot of the element.
|
|
78
78
|
*/
|
|
79
|
-
export function getElementScreenshot(this:
|
|
79
|
+
export declare function getElementScreenshot(this: AndroidUiautomator2Driver, element: string): Promise<string>;
|
|
80
80
|
/**
|
|
81
|
-
*
|
|
82
|
-
* @param
|
|
83
|
-
* @returns {Promise<void>}
|
|
81
|
+
* Clears the element text.
|
|
82
|
+
* @param elementId - ID of the element to clear.
|
|
84
83
|
*/
|
|
85
|
-
export function clear(this:
|
|
84
|
+
export declare function clear(this: AndroidUiautomator2Driver, elementId: string): Promise<void>;
|
|
86
85
|
/**
|
|
87
|
-
*
|
|
88
|
-
* @param
|
|
89
|
-
* @returns
|
|
86
|
+
* Gets the element rectangle.
|
|
87
|
+
* @param elementId - ID of the element.
|
|
88
|
+
* @returns The element rectangle (x, y, width, height).
|
|
90
89
|
*/
|
|
91
|
-
export function getElementRect(this:
|
|
90
|
+
export declare function getElementRect(this: AndroidUiautomator2Driver, elementId: string): Promise<Rect>;
|
|
92
91
|
/**
|
|
93
|
-
*
|
|
94
|
-
* @
|
|
95
|
-
* @param
|
|
96
|
-
* @param {string} text The actual text to set.
|
|
97
|
-
* @throws {Error} If there was a faulre while setting the text
|
|
98
|
-
* @returns {Promise<void>}
|
|
92
|
+
* Replaces the element text.
|
|
93
|
+
* @param elementId - ID of the element.
|
|
94
|
+
* @param text - Text to replace the current element value with.
|
|
99
95
|
*/
|
|
100
|
-
export function mobileReplaceElementValue(this:
|
|
101
|
-
export type AndroidUiautomator2Driver = import("../driver").AndroidUiautomator2Driver;
|
|
96
|
+
export declare function mobileReplaceElementValue(this: AndroidUiautomator2Driver, elementId: string, text: string): Promise<void>;
|
|
102
97
|
//# sourceMappingURL=element.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"element.d.ts","sourceRoot":"","sources":["../../../lib/commands/element.
|
|
1
|
+
{"version":3,"file":"element.d.ts","sourceRoot":"","sources":["../../../lib/commands/element.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAC,qBAAqB,EAAC,MAAM,uBAAuB,CAAC;AACjE,OAAO,KAAK,EAAC,OAAO,IAAI,aAAa,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAC,MAAM,eAAe,CAAC;AAClF,OAAO,KAAK,EAAC,yBAAyB,EAAC,MAAM,WAAW,CAAC;AAGzD;;;GAGG;AACH,wBAAsB,MAAM,CAAC,IAAI,EAAE,yBAAyB,GAAG,OAAO,CAAC,aAAa,CAAC,CAEpF;AAED;;;;;GAKG;AACH,wBAAsB,YAAY,CAAC,IAAI,EAAE,yBAAyB,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAEzH;AAED;;;;GAIG;AACH,wBAAsB,gBAAgB,CAAC,IAAI,EAAE,yBAAyB,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAE3G;AAED;;;;GAIG;AACH,wBAAsB,cAAc,CAAC,IAAI,EAAE,yBAAyB,E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AK,CAAC,IAAI,EAAE,yBAAyB,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAE7F;AAED;;;;GAIG;AACH,wBAAsB,cAAc,CAAC,IAAI,EAAE,yBAAyB,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CActG;AAED;;;;GAIG;AACH,wBAAsB,yBAAyB,CAC7C,IAAI,EAAE,yBAAyB,EAC/B,SAAS,EAAE,MAAM,EACjB,IAAI,EAAE,MAAM,GACX,OAAO,CAAC,IAAI,CAAC,CAKf"}
|
|
@@ -19,86 +19,84 @@ exports.getElementScreenshot = getElementScreenshot;
|
|
|
19
19
|
exports.clear = clear;
|
|
20
20
|
exports.getElementRect = getElementRect;
|
|
21
21
|
exports.mobileReplaceElementValue = mobileReplaceElementValue;
|
|
22
|
+
const driver_1 = require("appium/driver");
|
|
22
23
|
const bluebird_1 = __importDefault(require("bluebird"));
|
|
23
24
|
const lodash_1 = __importDefault(require("lodash"));
|
|
24
|
-
const driver_1 = require("appium/driver");
|
|
25
25
|
/**
|
|
26
|
-
*
|
|
27
|
-
* @returns
|
|
26
|
+
* Gets the currently active element.
|
|
27
|
+
* @returns The currently active element.
|
|
28
28
|
*/
|
|
29
29
|
async function active() {
|
|
30
|
-
return
|
|
30
|
+
return (await this.uiautomator2.jwproxy.command('/element/active', 'GET'));
|
|
31
31
|
}
|
|
32
32
|
/**
|
|
33
|
-
*
|
|
34
|
-
* @param
|
|
35
|
-
* @param
|
|
36
|
-
* @returns
|
|
33
|
+
* Gets an element attribute value.
|
|
34
|
+
* @param attribute - Name of the attribute to retrieve.
|
|
35
|
+
* @param elementId - ID of the element.
|
|
36
|
+
* @returns The attribute value as a string.
|
|
37
37
|
*/
|
|
38
38
|
async function getAttribute(attribute, elementId) {
|
|
39
39
|
return String(await this.uiautomator2.jwproxy.command(`/element/${elementId}/attribute/${attribute}`, 'GET', {}));
|
|
40
40
|
}
|
|
41
41
|
/**
|
|
42
|
-
*
|
|
43
|
-
* @param
|
|
44
|
-
* @returns
|
|
42
|
+
* Returns whether the element is displayed.
|
|
43
|
+
* @param elementId - ID of the element.
|
|
44
|
+
* @returns True if the element is displayed, false otherwise.
|
|
45
45
|
*/
|
|
46
46
|
async function elementDisplayed(elementId) {
|
|
47
47
|
return toBool(await this.getAttribute('displayed', elementId));
|
|
48
48
|
}
|
|
49
49
|
/**
|
|
50
|
-
*
|
|
51
|
-
* @param
|
|
52
|
-
* @returns
|
|
50
|
+
* Returns whether the element is enabled.
|
|
51
|
+
* @param elementId - ID of the element.
|
|
52
|
+
* @returns True if the element is enabled, false otherwise.
|
|
53
53
|
*/
|
|
54
54
|
async function elementEnabled(elementId) {
|
|
55
55
|
return toBool(await this.getAttribute('enabled', elementId));
|
|
56
56
|
}
|
|
57
57
|
/**
|
|
58
|
-
*
|
|
59
|
-
* @param
|
|
60
|
-
* @returns
|
|
58
|
+
* Returns whether the element is selected.
|
|
59
|
+
* @param elementId - ID of the element.
|
|
60
|
+
* @returns True if the element is selected, false otherwise.
|
|
61
61
|
*/
|
|
62
62
|
async function elementSelected(elementId) {
|
|
63
63
|
return toBool(await this.getAttribute('selected', elementId));
|
|
64
64
|
}
|
|
65
65
|
/**
|
|
66
|
-
*
|
|
67
|
-
* @param
|
|
68
|
-
* @returns
|
|
66
|
+
* Gets the element tag name.
|
|
67
|
+
* @param elementId - ID of the element.
|
|
68
|
+
* @returns The element tag name.
|
|
69
69
|
*/
|
|
70
70
|
async function getName(elementId) {
|
|
71
|
-
return
|
|
71
|
+
return (await this.uiautomator2.jwproxy.command(`/element/${elementId}/name`, 'GET', {}));
|
|
72
72
|
}
|
|
73
73
|
/**
|
|
74
|
-
*
|
|
75
|
-
* @param
|
|
76
|
-
* @returns
|
|
74
|
+
* Gets the element location.
|
|
75
|
+
* @param elementId - ID of the element.
|
|
76
|
+
* @returns The element position coordinates (x, y).
|
|
77
77
|
*/
|
|
78
78
|
async function getLocation(elementId) {
|
|
79
|
-
return
|
|
79
|
+
return (await this.uiautomator2.jwproxy.command(`/element/${elementId}/location`, 'GET', {}));
|
|
80
80
|
}
|
|
81
81
|
/**
|
|
82
|
-
*
|
|
83
|
-
* @param
|
|
84
|
-
* @returns
|
|
82
|
+
* Gets the element size.
|
|
83
|
+
* @param elementId - ID of the element.
|
|
84
|
+
* @returns The element size (width, height).
|
|
85
85
|
*/
|
|
86
86
|
async function getSize(elementId) {
|
|
87
|
-
return
|
|
87
|
+
return (await this.uiautomator2.jwproxy.command(`/element/${elementId}/size`, 'GET', {}));
|
|
88
88
|
}
|
|
89
89
|
/**
|
|
90
|
-
*
|
|
91
|
-
* @param
|
|
92
|
-
* @returns {Promise<void>}
|
|
90
|
+
* Sets the value of an element using the upstream driver API.
|
|
91
|
+
* @param params - Options containing the element ID and value to set.
|
|
93
92
|
*/
|
|
94
93
|
async function doSetElementValue(params) {
|
|
95
94
|
await this.uiautomator2.jwproxy.command(`/element/${params.elementId}/value`, 'POST', params);
|
|
96
95
|
}
|
|
97
96
|
/**
|
|
98
|
-
*
|
|
99
|
-
* @param
|
|
100
|
-
* @param
|
|
101
|
-
* @returns {Promise<void>}
|
|
97
|
+
* Sends text to an element without replacement.
|
|
98
|
+
* @param keys - Text to send, either as a string or array of strings (which will be joined).
|
|
99
|
+
* @param elementId - ID of the element.
|
|
102
100
|
*/
|
|
103
101
|
async function setValueImmediate(keys, elementId) {
|
|
104
102
|
await this.uiautomator2.jwproxy.command(`/element/${elementId}/value`, 'POST', {
|
|
@@ -108,67 +106,58 @@ async function setValueImmediate(keys, elementId) {
|
|
|
108
106
|
});
|
|
109
107
|
}
|
|
110
108
|
/**
|
|
111
|
-
*
|
|
112
|
-
* @param
|
|
113
|
-
* @returns
|
|
109
|
+
* Gets the element text.
|
|
110
|
+
* @param elementId - ID of the element.
|
|
111
|
+
* @returns The element text content.
|
|
114
112
|
*/
|
|
115
113
|
async function getText(elementId) {
|
|
116
114
|
return String(await this.uiautomator2.jwproxy.command(`/element/${elementId}/text`, 'GET', {}));
|
|
117
115
|
}
|
|
118
116
|
/**
|
|
119
|
-
*
|
|
120
|
-
* @param
|
|
121
|
-
* @returns {Promise<void>}
|
|
117
|
+
* Clicks the given element.
|
|
118
|
+
* @param element - ID of the element to click.
|
|
122
119
|
*/
|
|
123
120
|
async function click(element) {
|
|
124
121
|
await this.uiautomator2.jwproxy.command(`/element/${element}/click`, 'POST', { element });
|
|
125
122
|
}
|
|
126
123
|
/**
|
|
127
|
-
*
|
|
128
|
-
* @param
|
|
129
|
-
* @returns
|
|
124
|
+
* Takes a screenshot of the element.
|
|
125
|
+
* @param element - ID of the element.
|
|
126
|
+
* @returns Base64-encoded PNG screenshot of the element.
|
|
130
127
|
*/
|
|
131
128
|
async function getElementScreenshot(element) {
|
|
132
129
|
return String(await this.uiautomator2.jwproxy.command(`/element/${element}/screenshot`, 'GET', {}));
|
|
133
130
|
}
|
|
134
131
|
/**
|
|
135
|
-
*
|
|
136
|
-
* @param
|
|
137
|
-
* @returns {Promise<void>}
|
|
132
|
+
* Clears the element text.
|
|
133
|
+
* @param elementId - ID of the element to clear.
|
|
138
134
|
*/
|
|
139
135
|
async function clear(elementId) {
|
|
140
|
-
await this.uiautomator2.jwproxy.command(`/element/${elementId}/clear`, 'POST', {
|
|
141
|
-
elementId,
|
|
142
|
-
});
|
|
136
|
+
await this.uiautomator2.jwproxy.command(`/element/${elementId}/clear`, 'POST', { elementId });
|
|
143
137
|
}
|
|
144
138
|
/**
|
|
145
|
-
*
|
|
146
|
-
* @param
|
|
147
|
-
* @returns
|
|
139
|
+
* Gets the element rectangle.
|
|
140
|
+
* @param elementId - ID of the element.
|
|
141
|
+
* @returns The element rectangle (x, y, width, height).
|
|
148
142
|
*/
|
|
149
143
|
async function getElementRect(elementId) {
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
}
|
|
161
|
-
return /** @type {import('@appium/types').Rect} */ (await chromedriver.jwproxy.command(`/element/${elementId}/rect`, 'GET'));
|
|
144
|
+
if (!this.isWebContext()) {
|
|
145
|
+
return (await this.uiautomator2.jwproxy.command(`/element/${elementId}/rect`, 'GET'));
|
|
146
|
+
}
|
|
147
|
+
const chromedriver = this.chromedriver;
|
|
148
|
+
if (chromedriver.jwproxy.downstreamProtocol === driver_1.PROTOCOLS.MJSONWP) {
|
|
149
|
+
const [{ x, y }, { width, height }] = (await bluebird_1.default.all([
|
|
150
|
+
chromedriver.jwproxy.command(`/element/${elementId}/location`, 'GET'),
|
|
151
|
+
chromedriver.jwproxy.command(`/element/${elementId}/size`, 'GET'),
|
|
152
|
+
]));
|
|
153
|
+
return { x, y, width, height };
|
|
162
154
|
}
|
|
163
|
-
return
|
|
155
|
+
return (await chromedriver.jwproxy.command(`/element/${elementId}/rect`, 'GET'));
|
|
164
156
|
}
|
|
165
157
|
/**
|
|
166
|
-
*
|
|
167
|
-
* @
|
|
168
|
-
* @param
|
|
169
|
-
* @param {string} text The actual text to set.
|
|
170
|
-
* @throws {Error} If there was a faulre while setting the text
|
|
171
|
-
* @returns {Promise<void>}
|
|
158
|
+
* Replaces the element text.
|
|
159
|
+
* @param elementId - ID of the element.
|
|
160
|
+
* @param text - Text to replace the current element value with.
|
|
172
161
|
*/
|
|
173
162
|
async function mobileReplaceElementValue(elementId, text) {
|
|
174
163
|
await this.uiautomator2.jwproxy.command(`/element/${elementId}/value`, 'POST', {
|
|
@@ -176,16 +165,7 @@ async function mobileReplaceElementValue(elementId, text) {
|
|
|
176
165
|
replace: true,
|
|
177
166
|
});
|
|
178
167
|
}
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
* @param {any} s
|
|
182
|
-
* @returns {boolean}
|
|
183
|
-
*/
|
|
184
|
-
function toBool(s) {
|
|
185
|
-
return lodash_1.default.isString(s) ? s.toLowerCase() === 'true' : !!s;
|
|
168
|
+
function toBool(value) {
|
|
169
|
+
return lodash_1.default.isString(value) ? value.toLowerCase() === 'true' : !!value;
|
|
186
170
|
}
|
|
187
|
-
// #endregion
|
|
188
|
-
/**
|
|
189
|
-
* @typedef {import('../driver').AndroidUiautomator2Driver} AndroidUiautomator2Driver
|
|
190
|
-
*/
|
|
191
171
|
//# sourceMappingURL=element.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"element.js","sourceRoot":"","sources":["../../../lib/commands/element.
|
|
1
|
+
{"version":3,"file":"element.js","sourceRoot":"","sources":["../../../lib/commands/element.ts"],"names":[],"mappings":";;;;;AAYA,wBAEC;AAQD,oCAEC;AAOD,4CAEC;AAOD,wCAEC;AAOD,0CAEC;AAOD,0BAEC;AAOD,kCAEC;AAOD,0BAEC;AAMD,8CAEC;AAOD,8CAUC;AAOD,0BAEC;AAMD,sBAEC;AAOD,oDAEC;AAMD,sBAEC;AAOD,wCAcC;AAOD,8DASC;AA9KD,0CAAwC;AACxC,wDAAyB;AACzB,oDAAuB;AAMvB;;;GAGG;AACI,KAAK,UAAU,MAAM;IAC1B,OAAO,CAAC,MAAM,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,OAAO,CAAC,iBAAiB,EAAE,KAAK,CAAC,CAAkB,CAAC;AAC9F,CAAC;AAED;;;;;GAKG;AACI,KAAK,UAAU,YAAY,CAAkC,SAAiB,EAAE,SAAiB;IACtG,OAAO,MAAM,CAAC,MAAM,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,OAAO,CAAC,YAAY,SAAS,cAAc,SAAS,EAAE,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC,CAAC;AACpH,CAAC;AAED;;;;GAIG;AACI,KAAK,UAAU,gBAAgB,CAAkC,SAAiB;IACvF,OAAO,MAAM,CAAC,MAAM,IAAI,CAAC,YAAY,CAAC,WAAW,EAAE,SAAS,CAAC,CAAC,CAAC;AACjE,CAAC;AAED;;;;GAIG;AACI,KAAK,UAAU,cAAc,CAAkC,SAAiB;IACrF,OAAO,M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AAC;IACvD,IAAI,YAAY,CAAC,OAAO,CAAC,kBAAkB,KAAK,kBAAS,CAAC,OAAO,EAAE,CAAC;QAClE,MAAM,CAAC,EAAC,CAAC,EAAE,CAAC,EAAC,EAAE,EAAC,KAAK,EAAE,MAAM,EAAC,CAAC,GAAG,CAAC,MAAM,kBAAC,CAAC,GAAG,CAAC;YAC7C,YAAY,CAAC,OAAO,CAAC,OAAO,CAAC,YAAY,SAAS,WAAW,EAAE,KAAK,CAAC;YACrE,YAAY,CAAC,OAAO,CAAC,OAAO,CAAC,YAAY,SAAS,OAAO,EAAE,KAAK,CAAC;SAClE,CAAC,CAAqB,CAAC;QACxB,OAAO,EAAC,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,EAAC,CAAC;IAC/B,CAAC;IACD,OAAO,CAAC,MAAM,YAAY,CAAC,OAAO,CAAC,OAAO,CAAC,YAAY,SAAS,OAAO,EAAE,KAAK,CAAC,CAAS,CAAC;AAC3F,CAAC;AAED;;;;GAIG;AACI,KAAK,UAAU,yBAAyB,CAE7C,SAAiB,EACjB,IAAY;IAEZ,MAAM,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,OAAO,CAAC,YAAY,SAAS,QAAQ,EAAE,MAAM,EAAE;QAC7E,IAAI;QACJ,OAAO,EAAE,IAAI;KACd,CAAC,CAAC;AACL,CAAC;AAED,SAAS,MAAM,CAAC,KAAU;IACxB,OAAO,gBAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,WAAW,EAAE,KAAK,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;AACtE,CAAC"}
|
|
@@ -1,12 +1,16 @@
|
|
|
1
|
+
import type { Element as AppiumElement } from '@appium/types';
|
|
2
|
+
import type { FindElementOpts } from 'appium-android-driver';
|
|
3
|
+
import type { AndroidUiautomator2Driver } from '../driver';
|
|
1
4
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
* @
|
|
6
|
-
* @param {import('appium-android-driver').FindElementOpts} params
|
|
7
|
-
* @returns {Promise<Element | Element[]>}
|
|
5
|
+
* Overrides helpers.doFindElementOrEls functionality of appium-android-driver.
|
|
6
|
+
* Handles special xpath selectors and CSS selector conversion.
|
|
7
|
+
* @param params - Element finding options including strategy, selector, context, and multiple flag.
|
|
8
|
+
* @returns A single element if `params.multiple` is false, or an array of elements if true.
|
|
8
9
|
*/
|
|
9
|
-
export function doFindElementOrEls(this:
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
export declare function doFindElementOrEls(this: AndroidUiautomator2Driver, params: FindElementOpts & {
|
|
11
|
+
multiple: true;
|
|
12
|
+
}): Promise<AppiumElement[]>;
|
|
13
|
+
export declare function doFindElementOrEls(this: AndroidUiautomator2Driver, params: FindElementOpts & {
|
|
14
|
+
multiple: false;
|
|
15
|
+
}): Promise<AppiumElement>;
|
|
12
16
|
//# sourceMappingURL=find.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"find.d.ts","sourceRoot":"","sources":["../../../lib/commands/find.
|
|
1
|
+
{"version":3,"file":"find.d.ts","sourceRoot":"","sources":["../../../lib/commands/find.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,OAAO,IAAI,aAAa,EAAC,MAAM,eAAe,CAAC;AAC5D,OAAO,KAAK,EAAC,eAAe,EAAC,MAAM,uBAAuB,CAAC;AAC3D,OAAO,KAAK,EAAC,yBAAyB,EAAC,MAAM,WAAW,CAAC;AASzD;;;;;GAKG;AACH,wBAAsB,kBAAkB,CACtC,IAAI,EAAE,yBAAyB,EAC/B,MAAM,EAAE,eAAe,GAAG;IAAC,QAAQ,EAAE,IAAI,CAAA;CAAC,GACzC,OAAO,CAAC,aAAa,EAAE,CAAC,CAAC;AAC5B,wBAAsB,kBAAkB,CACtC,IAAI,EAAE,yBAAyB,EAC/B,MAAM,EAAE,eAAe,GAAG;IAAC,QAAQ,EAAE,KAAK,CAAA;CAAC,GAC1C,OAAO,CAAC,aAAa,CAAC,CAAC"}
|
|
@@ -7,19 +7,11 @@ const css_converter_1 = require("../css-converter");
|
|
|
7
7
|
const MAGIC_FIRST_VIS_CHILD_SEL = /\/\*\[@firstVisible ?= ?('|")true\1\]/;
|
|
8
8
|
const MAGIC_SCROLLABLE_SEL = /\/\/\*\[@scrollable ?= ?('|")true\1\]/;
|
|
9
9
|
const MAGIC_SCROLLABLE_BY = 'new UiSelector().scrollable(true)';
|
|
10
|
-
/**
|
|
11
|
-
* @privateRemarks Overriding helpers.doFindElementOrEls functionality of appium-android-driver,
|
|
12
|
-
* this.element initialized in find.js of appium-android-drive.
|
|
13
|
-
*
|
|
14
|
-
* @this {AndroidUiautomator2Driver}
|
|
15
|
-
* @param {import('appium-android-driver').FindElementOpts} params
|
|
16
|
-
* @returns {Promise<Element | Element[]>}
|
|
17
|
-
*/
|
|
18
10
|
async function doFindElementOrEls(params) {
|
|
19
|
-
const uiautomator2 =
|
|
11
|
+
const uiautomator2 = this.uiautomator2;
|
|
20
12
|
if (params.strategy === 'xpath' && MAGIC_FIRST_VIS_CHILD_SEL.test(params.selector)) {
|
|
21
|
-
|
|
22
|
-
return
|
|
13
|
+
const elementId = params.context;
|
|
14
|
+
return (await uiautomator2.jwproxy.command(`/appium/element/${elementId}/first_visible`, 'GET', {}));
|
|
23
15
|
}
|
|
24
16
|
if (params.strategy === 'xpath' && MAGIC_SCROLLABLE_SEL.test(params.selector)) {
|
|
25
17
|
params.strategy = '-android uiautomator';
|
|
@@ -29,10 +21,6 @@ async function doFindElementOrEls(params) {
|
|
|
29
21
|
params.strategy = '-android uiautomator';
|
|
30
22
|
params.selector = new css_converter_1.CssConverter(params.selector, this.opts.appPackage).toUiAutomatorSelector();
|
|
31
23
|
}
|
|
32
|
-
return
|
|
24
|
+
return (await uiautomator2.jwproxy.command(`/element${params.multiple ? 's' : ''}`, 'POST', params));
|
|
33
25
|
}
|
|
34
|
-
/**
|
|
35
|
-
* @typedef {import('@appium/types').Element} Element
|
|
36
|
-
* @typedef {import('../driver').AndroidUiautomator2Driver} AndroidUiautomator2Driver
|
|
37
|
-
*/
|
|
38
26
|
//# sourceMappingURL=find.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"find.js","sourceRoot":"","sources":["../../../lib/commands/find.
|
|
1
|
+
{"version":3,"file":"find.js","sourceRoot":"","sources":["../../../lib/commands/find.ts"],"names":[],"mappings":";;AA0BA,gDAoBC;AA9CD,oDAA8C;AAK9C,4EAA4E;AAC5E,sCAAsC;AACtC,MAAM,yBAAyB,GAAG,uCAAuC,CAAC;AAE1E,MAAM,oBAAoB,GAAG,uCAAuC,CAAC;AACrE,MAAM,mBAAmB,GAAG,mCAAmC,CAAC;AAgBzD,KAAK,UAAU,kBAAkB,CAEtC,MAAuB;IAEvB,MAAM,YAAY,GAAG,IAAI,CAAC,YAAY,CAAC;IACvC,IAAI,MAAM,CAAC,QAAQ,KAAK,OAAO,IAAI,yBAAyB,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC;QACnF,MAAM,SAAS,GAAG,MAAM,CAAC,OAAO,CAAC;QACjC,OAAO,CAAC,MAAM,YAAY,CAAC,OAAO,CAAC,OAAO,CAAC,mBAAmB,SAAS,gBAAgB,EAAE,KAAK,EAAE,EAAE,CAAC,CAAkB,CAAC;IACxH,CAAC;IACD,IAAI,MAAM,CAAC,QAAQ,KAAK,OAAO,IAAI,oBAAoB,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC9E,MAAM,CAAC,QAAQ,GAAG,sBAAsB,CAAC;QACzC,MAAM,CAAC,QAAQ,GAAG,mBAAmB,CAAC;IACxC,CAAC;IACD,IAAI,MAAM,CAAC,QAAQ,KAAK,cAAc,EAAE,CAAC;QACvC,MAAM,CAAC,QAAQ,GAAG,sBAAsB,CAAC;QACzC,MAAM,CAAC,QAAQ,GAAG,IAAI,4BAAY,CA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