appium-uiautomator2-driver 2.45.0 → 3.0.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 +27 -0
- package/README.md +1 -1
- package/build/lib/commands/actions.d.ts +11 -0
- package/build/lib/commands/actions.d.ts.map +1 -1
- package/build/lib/commands/actions.js +30 -1
- package/build/lib/commands/actions.js.map +1 -1
- package/build/lib/commands/gestures.js +1 -1
- package/build/lib/commands/gestures.js.map +1 -1
- package/build/lib/driver.d.ts +3 -70
- package/build/lib/driver.d.ts.map +1 -1
- package/build/lib/driver.js +2 -15
- package/build/lib/driver.js.map +1 -1
- package/build/lib/method-map.d.ts +0 -58
- package/build/lib/method-map.d.ts.map +1 -1
- package/build/tsconfig.tsbuildinfo +1 -1
- package/lib/commands/actions.js +39 -0
- package/lib/commands/gestures.js +1 -1
- package/lib/driver.ts +4 -27
- package/npm-shrinkwrap.json +25 -16
- package/package.json +3 -3
- package/build/lib/commands/touch.d.ts +0 -83
- package/build/lib/commands/touch.d.ts.map +0 -1
- package/build/lib/commands/touch.js +0 -167
- package/build/lib/commands/touch.js.map +0 -1
- package/lib/commands/touch.js +0 -213
package/lib/commands/touch.js
DELETED
|
@@ -1,213 +0,0 @@
|
|
|
1
|
-
import { util } from 'appium/support';
|
|
2
|
-
import { W3C_ELEMENT_KEY } from 'appium/driver';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* @deprecated
|
|
6
|
-
* @this {AndroidUiautomator2Driver}
|
|
7
|
-
* @param {import('appium-android-driver').SwipeOpts} swipeOpts
|
|
8
|
-
* @returns {Promise<void>}
|
|
9
|
-
*/
|
|
10
|
-
export async function doSwipe(swipeOpts) {
|
|
11
|
-
await this.uiautomator2.jwproxy.command(
|
|
12
|
-
`/touch/perform`,
|
|
13
|
-
'POST',
|
|
14
|
-
swipeOpts
|
|
15
|
-
);
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* @deprecated
|
|
20
|
-
* @this {AndroidUiautomator2Driver}
|
|
21
|
-
* @param {import('appium-android-driver').DragOpts} dragOpts
|
|
22
|
-
* @returns {Promise<void>}
|
|
23
|
-
*/
|
|
24
|
-
export async function doDrag(dragOpts) {
|
|
25
|
-
await this.uiautomator2.jwproxy.command(
|
|
26
|
-
`/touch/drag`,
|
|
27
|
-
'POST',
|
|
28
|
-
dragOpts
|
|
29
|
-
);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* @deprecated
|
|
34
|
-
* @this {AndroidUiautomator2Driver}
|
|
35
|
-
* @param {string} element
|
|
36
|
-
* @param {number} x
|
|
37
|
-
* @param {number} y
|
|
38
|
-
* @param {number} duration
|
|
39
|
-
* @returns {Promise<void>}
|
|
40
|
-
*/
|
|
41
|
-
export async function touchLongClick(element, x, y, duration) {
|
|
42
|
-
let params = {element, x, y, duration};
|
|
43
|
-
await this.uiautomator2.jwproxy.command(
|
|
44
|
-
`/touch/longclick`,
|
|
45
|
-
'POST',
|
|
46
|
-
{params}
|
|
47
|
-
);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* @deprecated
|
|
52
|
-
* @this {AndroidUiautomator2Driver}
|
|
53
|
-
* @param {string} element
|
|
54
|
-
* @param {number} x
|
|
55
|
-
* @param {number} y
|
|
56
|
-
* @returns {Promise<void>}
|
|
57
|
-
*/
|
|
58
|
-
export async function touchDown(element, x, y) {
|
|
59
|
-
let params = {element, x, y};
|
|
60
|
-
await this.uiautomator2.jwproxy.command(
|
|
61
|
-
`/touch/down`,
|
|
62
|
-
'POST',
|
|
63
|
-
{params}
|
|
64
|
-
);
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
/**
|
|
68
|
-
* @deprecated
|
|
69
|
-
* @this {AndroidUiautomator2Driver}
|
|
70
|
-
* @param {string} element
|
|
71
|
-
* @param {number} x
|
|
72
|
-
* @param {number} y
|
|
73
|
-
* @returns {Promise<void>}
|
|
74
|
-
*/
|
|
75
|
-
export async function touchUp(element, x, y) {
|
|
76
|
-
let params = {element, x, y};
|
|
77
|
-
await this.uiautomator2.jwproxy.command(
|
|
78
|
-
`/touch/up`,
|
|
79
|
-
'POST',
|
|
80
|
-
{params}
|
|
81
|
-
);
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
* @deprecated
|
|
86
|
-
* @this {AndroidUiautomator2Driver}
|
|
87
|
-
* @param {string} element
|
|
88
|
-
* @param {number} x
|
|
89
|
-
* @param {number} y
|
|
90
|
-
* @returns {Promise<void>}
|
|
91
|
-
*/
|
|
92
|
-
export async function touchMove(element, x, y) {
|
|
93
|
-
let params = {element, x, y};
|
|
94
|
-
await this.uiautomator2.jwproxy.command(
|
|
95
|
-
`/touch/move`,
|
|
96
|
-
'POST',
|
|
97
|
-
{params}
|
|
98
|
-
);
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
/**
|
|
102
|
-
* @deprecated
|
|
103
|
-
* @this {AndroidUiautomator2Driver}
|
|
104
|
-
* @param {string?} [elementId=null]
|
|
105
|
-
* @param {number?} [x=null]
|
|
106
|
-
* @param {number?} [y=null]
|
|
107
|
-
* @param {number} [count=1]
|
|
108
|
-
* @returns {Promise<void>}
|
|
109
|
-
*/
|
|
110
|
-
export async function tap(elementId = null, x = null, y = null, count = 1) {
|
|
111
|
-
const areCoordinatesDefined = util.hasValue(x) && util.hasValue(y);
|
|
112
|
-
if (!util.hasValue(elementId) && !areCoordinatesDefined) {
|
|
113
|
-
throw new Error(`Either element id to tap or both absolute coordinates should be defined`);
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
for (let i = 0; i < count; i++) {
|
|
117
|
-
if (util.hasValue(elementId) && !areCoordinatesDefined) {
|
|
118
|
-
// we are either tapping on the default location of the element
|
|
119
|
-
// or an offset from the top left corner
|
|
120
|
-
await this.uiautomator2.jwproxy.command(
|
|
121
|
-
`/element/${elementId}/click`,
|
|
122
|
-
'POST'
|
|
123
|
-
);
|
|
124
|
-
} else {
|
|
125
|
-
await this.uiautomator2.jwproxy.command(
|
|
126
|
-
`/appium/tap`,
|
|
127
|
-
'POST',
|
|
128
|
-
{
|
|
129
|
-
x,
|
|
130
|
-
y,
|
|
131
|
-
[W3C_ELEMENT_KEY]: elementId,
|
|
132
|
-
}
|
|
133
|
-
);
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
/**
|
|
139
|
-
* @deprecated
|
|
140
|
-
* @this {AndroidUiautomator2Driver}
|
|
141
|
-
* @param {string} elementId
|
|
142
|
-
* @param {import('appium-android-driver').TouchState[]} states
|
|
143
|
-
* @returns {Promise<void>}
|
|
144
|
-
*/
|
|
145
|
-
export async function doPerformMultiAction(elementId, states) {
|
|
146
|
-
let opts;
|
|
147
|
-
if (elementId) {
|
|
148
|
-
opts = {
|
|
149
|
-
elementId,
|
|
150
|
-
actions: states,
|
|
151
|
-
};
|
|
152
|
-
|
|
153
|
-
await this.uiautomator2.jwproxy.command(
|
|
154
|
-
'/touch/multi/perform',
|
|
155
|
-
'POST',
|
|
156
|
-
opts
|
|
157
|
-
);
|
|
158
|
-
} else {
|
|
159
|
-
opts = {
|
|
160
|
-
actions: states,
|
|
161
|
-
};
|
|
162
|
-
await this.uiautomator2.jwproxy.command(
|
|
163
|
-
'/touch/multi/perform',
|
|
164
|
-
'POST',
|
|
165
|
-
opts
|
|
166
|
-
);
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
/**
|
|
171
|
-
* @this {AndroidUiautomator2Driver}
|
|
172
|
-
* @param {import('@appium/types').StringRecord} actions
|
|
173
|
-
* @returns {Promise<void>}
|
|
174
|
-
*/
|
|
175
|
-
export async function performActions(actions) {
|
|
176
|
-
this.log.debug(`Received the following W3C actions: ${JSON.stringify(actions, null, ' ')}`);
|
|
177
|
-
// This is mandatory, since Selenium API uses MOUSE as the default pointer type
|
|
178
|
-
const preprocessedActions = actions.map((action) =>
|
|
179
|
-
Object.assign(
|
|
180
|
-
{},
|
|
181
|
-
action,
|
|
182
|
-
action.type === 'pointer'
|
|
183
|
-
? {
|
|
184
|
-
parameters: {
|
|
185
|
-
pointerType: 'touch',
|
|
186
|
-
},
|
|
187
|
-
}
|
|
188
|
-
: {}
|
|
189
|
-
)
|
|
190
|
-
);
|
|
191
|
-
this.log.debug(`Preprocessed actions: ${JSON.stringify(preprocessedActions, null, ' ')}`);
|
|
192
|
-
await this.uiautomator2.jwproxy.command(
|
|
193
|
-
'/actions',
|
|
194
|
-
'POST',
|
|
195
|
-
{
|
|
196
|
-
actions: preprocessedActions,
|
|
197
|
-
}
|
|
198
|
-
);
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
/**
|
|
202
|
-
* @this {AndroidUiautomator2Driver}
|
|
203
|
-
* @returns {Promise<void>}
|
|
204
|
-
*/
|
|
205
|
-
// eslint-disable-next-line require-await
|
|
206
|
-
export async function releaseActions() {
|
|
207
|
-
this.log.info('On this platform, releaseActions is a no-op');
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
/**
|
|
211
|
-
* @typedef {import('../uiautomator2').UiAutomator2Server} UiAutomator2Server
|
|
212
|
-
* @typedef {import('../driver').AndroidUiautomator2Driver} AndroidUiautomator2Driver
|
|
213
|
-
*/
|