@appium/types 1.0.0 → 1.1.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/build/lib/capabilities.d.ts +1 -2
- package/build/lib/capabilities.d.ts.map +1 -1
- package/build/lib/{command.d.ts → command-maps.d.ts} +1 -1
- package/build/lib/command-maps.d.ts.map +1 -0
- package/build/lib/command-maps.js +4 -0
- package/build/lib/command-maps.js.map +1 -0
- package/build/lib/commands/appium.d.ts +100 -0
- package/build/lib/commands/appium.d.ts.map +1 -0
- package/build/lib/{command.js → commands/appium.js} +1 -2
- package/build/lib/commands/appium.js.map +1 -0
- package/build/lib/commands/basedriver.d.ts +370 -0
- package/build/lib/commands/basedriver.d.ts.map +1 -0
- package/build/lib/commands/basedriver.js +3 -0
- package/build/lib/commands/basedriver.js.map +1 -0
- package/build/lib/commands/index.d.ts +7 -0
- package/build/lib/commands/index.d.ts.map +1 -0
- package/build/lib/commands/index.js +23 -0
- package/build/lib/commands/index.js.map +1 -0
- package/build/lib/commands/jsonwp.d.ts +37 -0
- package/build/lib/commands/jsonwp.d.ts.map +1 -0
- package/build/lib/commands/jsonwp.js +3 -0
- package/build/lib/commands/jsonwp.js.map +1 -0
- package/build/lib/commands/mjsonwp.d.ts +65 -0
- package/build/lib/commands/mjsonwp.d.ts.map +1 -0
- package/build/lib/commands/mjsonwp.js +3 -0
- package/build/lib/commands/mjsonwp.js.map +1 -0
- package/build/lib/commands/other-protocols.d.ts +300 -0
- package/build/lib/commands/other-protocols.d.ts.map +1 -0
- package/build/lib/commands/other-protocols.js +3 -0
- package/build/lib/commands/other-protocols.js.map +1 -0
- package/build/lib/commands/webdriver.d.ts +443 -0
- package/build/lib/commands/webdriver.d.ts.map +1 -0
- package/build/lib/commands/webdriver.js +3 -0
- package/build/lib/commands/webdriver.js.map +1 -0
- package/build/lib/constraints.d.ts +19 -0
- package/build/lib/constraints.d.ts.map +1 -1
- package/build/lib/constraints.js.map +1 -1
- package/build/lib/driver.d.ts +9 -1056
- package/build/lib/driver.d.ts.map +1 -1
- package/build/lib/index.d.ts +2 -1
- package/build/lib/index.d.ts.map +1 -1
- package/build/lib/index.js +2 -1
- package/build/lib/index.js.map +1 -1
- package/build/lib/plugin.d.ts +1 -1
- package/build/lib/plugin.d.ts.map +1 -1
- package/build/lib/standard-caps.d.ts +8 -0
- package/build/lib/standard-caps.d.ts.map +1 -1
- package/lib/capabilities.ts +1 -2
- package/lib/commands/appium.ts +115 -0
- package/lib/commands/basedriver.ts +476 -0
- package/lib/commands/index.ts +6 -0
- package/lib/commands/jsonwp.ts +41 -0
- package/lib/commands/mjsonwp.ts +71 -0
- package/lib/commands/other-protocols.ts +387 -0
- package/lib/commands/webdriver.ts +511 -0
- package/lib/constraints.ts +18 -1
- package/lib/driver.ts +25 -1279
- package/lib/index.ts +2 -1
- package/lib/plugin.ts +1 -1
- package/lib/standard-caps.ts +8 -0
- package/package.json +5 -5
- package/build/lib/command.d.ts.map +0 -1
- package/build/lib/command.js.map +0 -1
- /package/lib/{command.ts → command-maps.ts} +0 -0
|
@@ -0,0 +1,476 @@
|
|
|
1
|
+
import type {DriverCaps, W3CDriverCaps} from '../capabilities';
|
|
2
|
+
import type {Constraints} from '../constraints';
|
|
3
|
+
import type {Element, StringRecord} from '../util';
|
|
4
|
+
|
|
5
|
+
export interface IBidiCommands {
|
|
6
|
+
bidiSubscribe(events: string[], contexts: string[]): Promise<void>;
|
|
7
|
+
bidiUnsubscribe(events: string[], contexts: string[]): Promise<void>;
|
|
8
|
+
bidiStatus(): Promise<DriverStatus>;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface DriverStatus {
|
|
12
|
+
ready: boolean,
|
|
13
|
+
message: string,
|
|
14
|
+
[key: string]: any;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface ITimeoutCommands {
|
|
18
|
+
/**
|
|
19
|
+
* Set the various timeouts associated with a session
|
|
20
|
+
* @see {@link https://w3c.github.io/webdriver/#set-timeouts}
|
|
21
|
+
*
|
|
22
|
+
* @param type - used only for the old (JSONWP) command, the type of the timeout
|
|
23
|
+
* @param ms - used only for the old (JSONWP) command, the ms for the timeout
|
|
24
|
+
* @param script - the number in ms for the script timeout, used for the W3C command
|
|
25
|
+
* @param pageLoad - the number in ms for the pageLoad timeout, used for the W3C command
|
|
26
|
+
* @param implicit - the number in ms for the implicit wait timeout, used for the W3C command
|
|
27
|
+
*/
|
|
28
|
+
timeouts(
|
|
29
|
+
type?: string,
|
|
30
|
+
ms?: number | string,
|
|
31
|
+
script?: number,
|
|
32
|
+
pageLoad?: number,
|
|
33
|
+
implicit?: number | string,
|
|
34
|
+
): Promise<void>;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Set the new command timeout
|
|
38
|
+
*
|
|
39
|
+
* @param ms - the timeout in ms
|
|
40
|
+
*/
|
|
41
|
+
setNewCommandTimeout(ms: number): void;
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* A helper method (not a command) used to set the implicit wait value
|
|
45
|
+
*
|
|
46
|
+
* @param ms - the implicit wait in ms
|
|
47
|
+
*/
|
|
48
|
+
setImplicitWait(ms: number): void;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Periodically retry an async function up until the currently set implicit wait timeout
|
|
52
|
+
*
|
|
53
|
+
* @param condition - the behaviour to retry until it returns truthy
|
|
54
|
+
*
|
|
55
|
+
* @returns The return value of the condition
|
|
56
|
+
*/
|
|
57
|
+
implicitWaitForCondition(condition: (...args: any[]) => Promise<any>): Promise<unknown>;
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Get the current timeouts
|
|
61
|
+
* @see {@link https://w3c.github.io/webdriver/#get-timeouts}
|
|
62
|
+
*
|
|
63
|
+
* @returns A map of timeout names to ms values
|
|
64
|
+
*/
|
|
65
|
+
getTimeouts(): Promise<Record<string, number>>;
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Set the implicit wait value that was sent in via the W3C protocol
|
|
69
|
+
*
|
|
70
|
+
* @param ms - the timeout in ms
|
|
71
|
+
*/
|
|
72
|
+
implicitWaitW3C(ms: number): Promise<void>;
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Set the page load timeout value that was sent in via the W3C protocol
|
|
76
|
+
*
|
|
77
|
+
* @param ms - the timeout in ms
|
|
78
|
+
*/
|
|
79
|
+
pageLoadTimeoutW3C(ms: number): Promise<void>;
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Set the script timeout value that was sent in via the W3C protocol
|
|
83
|
+
*
|
|
84
|
+
* @param ms - the timeout in ms
|
|
85
|
+
*/
|
|
86
|
+
scriptTimeoutW3C(ms: number): Promise<void>;
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Set Appium's new command timeout
|
|
90
|
+
*
|
|
91
|
+
* @param ms - the timeout in ms
|
|
92
|
+
*/
|
|
93
|
+
newCommandTimeout(ms: number): Promise<void>;
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Get a timeout value from a number or a string
|
|
97
|
+
*
|
|
98
|
+
* @param ms - the timeout value as a number or a string
|
|
99
|
+
*
|
|
100
|
+
* @returns The timeout as a number in ms
|
|
101
|
+
*/
|
|
102
|
+
parseTimeoutArgument(ms: number | string): number;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export interface IEventCommands {
|
|
106
|
+
/**
|
|
107
|
+
* Add a custom-named event to the Appium event log
|
|
108
|
+
*
|
|
109
|
+
* @param vendor - the name of the vendor or tool the event belongs to, to namespace the event
|
|
110
|
+
* @param event - the name of the event itself
|
|
111
|
+
*/
|
|
112
|
+
logCustomEvent(vendor: string, event: string): Promise<void>;
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Get a list of events that have occurred in the current session
|
|
116
|
+
*
|
|
117
|
+
* @param type - filter the returned events by including one or more types
|
|
118
|
+
*
|
|
119
|
+
* @returns The event history for the session
|
|
120
|
+
*/
|
|
121
|
+
getLogEvents(type?: string | string[]): Promise<EventHistory | Record<string, number>>;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
export interface EventHistory {
|
|
125
|
+
commands: EventHistoryCommand[];
|
|
126
|
+
[key: string]: any;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
export interface EventHistoryCommand {
|
|
130
|
+
cmd: string;
|
|
131
|
+
startTime: number;
|
|
132
|
+
endTime: number;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
export interface IExecuteCommands {
|
|
136
|
+
/**
|
|
137
|
+
* Call an `Execute Method` by its name with the given arguments. This method will check that the
|
|
138
|
+
* driver has registered the method matching the name, and send it the arguments.
|
|
139
|
+
*
|
|
140
|
+
* @param script - the name of the Execute Method
|
|
141
|
+
* @param args - a singleton array containing an arguments object
|
|
142
|
+
*
|
|
143
|
+
* @returns The result of calling the Execute Method
|
|
144
|
+
*/
|
|
145
|
+
executeMethod<
|
|
146
|
+
TArgs extends readonly any[] | readonly [StringRecord<unknown>] = unknown[],
|
|
147
|
+
TReturn = unknown,
|
|
148
|
+
>(
|
|
149
|
+
script: string,
|
|
150
|
+
args: TArgs,
|
|
151
|
+
): Promise<TReturn>;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
export interface IFindCommands {
|
|
155
|
+
/**
|
|
156
|
+
* Find a UI element given a locator strategy and a selector, erroring if it can't be found
|
|
157
|
+
* @see {@link https://w3c.github.io/webdriver/#find-element}
|
|
158
|
+
*
|
|
159
|
+
* @param strategy - the locator strategy
|
|
160
|
+
* @param selector - the selector to combine with the strategy to find the specific element
|
|
161
|
+
*
|
|
162
|
+
* @returns The element object encoding the element id which can be used in element-related
|
|
163
|
+
* commands
|
|
164
|
+
*/
|
|
165
|
+
findElement(strategy: string, selector: string): Promise<Element>;
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* Find a a list of all UI elements matching a given a locator strategy and a selector
|
|
169
|
+
* @see {@link https://w3c.github.io/webdriver/#find-elements}
|
|
170
|
+
*
|
|
171
|
+
* @param strategy - the locator strategy
|
|
172
|
+
* @param selector - the selector to combine with the strategy to find the specific elements
|
|
173
|
+
*
|
|
174
|
+
* @returns A possibly-empty list of element objects
|
|
175
|
+
*/
|
|
176
|
+
findElements(strategy: string, selector: string): Promise<Element[]>;
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* Find a UI element given a locator strategy and a selector, erroring if it can't be found. Only
|
|
180
|
+
* look for elements among the set of descendants of a given element
|
|
181
|
+
* @see {@link https://w3c.github.io/webdriver/#find-element-from-element}
|
|
182
|
+
*
|
|
183
|
+
* @param strategy - the locator strategy
|
|
184
|
+
* @param selector - the selector to combine with the strategy to find the specific element
|
|
185
|
+
* @param elementId - the id of the element to use as the search basis
|
|
186
|
+
*
|
|
187
|
+
* @returns The element object encoding the element id which can be used in element-related
|
|
188
|
+
* commands
|
|
189
|
+
*/
|
|
190
|
+
findElementFromElement(strategy: string, selector: string, elementId: string): Promise<Element>;
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* Find a a list of all UI elements matching a given a locator strategy and a selector. Only
|
|
194
|
+
* look for elements among the set of descendants of a given element
|
|
195
|
+
* @see {@link https://w3c.github.io/webdriver/#find-elements-from-element}
|
|
196
|
+
*
|
|
197
|
+
* @param strategy - the locator strategy
|
|
198
|
+
* @param selector - the selector to combine with the strategy to find the specific elements
|
|
199
|
+
* @param elementId - the id of the element to use as the search basis
|
|
200
|
+
*
|
|
201
|
+
* @returns A possibly-empty list of element objects
|
|
202
|
+
*/
|
|
203
|
+
findElementsFromElement(
|
|
204
|
+
strategy: string,
|
|
205
|
+
selector: string,
|
|
206
|
+
elementId: string,
|
|
207
|
+
): Promise<Element[]>;
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* Find an element from a shadow root
|
|
211
|
+
* @see {@link https://w3c.github.io/webdriver/#find-element-from-shadow-root}
|
|
212
|
+
* @param strategy - the locator strategy
|
|
213
|
+
* @param selector - the selector to combine with the strategy to find the specific elements
|
|
214
|
+
* @param shadowId - the id of the element to use as the search basis
|
|
215
|
+
*
|
|
216
|
+
* @returns The element inside the shadow root matching the selector
|
|
217
|
+
*/
|
|
218
|
+
findElementFromShadowRoot?(
|
|
219
|
+
strategy: string,
|
|
220
|
+
selector: string,
|
|
221
|
+
shadowId: string,
|
|
222
|
+
): Promise<Element>;
|
|
223
|
+
|
|
224
|
+
/**
|
|
225
|
+
* Find elements from a shadow root
|
|
226
|
+
* @see {@link https://w3c.github.io/webdriver/#find-element-from-shadow-root}
|
|
227
|
+
* @param strategy - the locator strategy
|
|
228
|
+
* @param selector - the selector to combine with the strategy to find the specific elements
|
|
229
|
+
* @param shadowId - the id of the element to use as the search basis
|
|
230
|
+
*
|
|
231
|
+
* @returns A possibly empty list of elements inside the shadow root matching the selector
|
|
232
|
+
*/
|
|
233
|
+
findElementsFromShadowRoot?(
|
|
234
|
+
strategy: string,
|
|
235
|
+
selector: string,
|
|
236
|
+
shadowId: string,
|
|
237
|
+
): Promise<Element[]>;
|
|
238
|
+
|
|
239
|
+
/**
|
|
240
|
+
* A helper method that returns one or more UI elements based on the search criteria
|
|
241
|
+
*
|
|
242
|
+
* @param strategy - the locator strategy
|
|
243
|
+
* @param selector - the selector
|
|
244
|
+
* @param mult - whether or not we want to find multiple elements
|
|
245
|
+
* @param context - the element to use as the search context basis if desiredCapabilities
|
|
246
|
+
*
|
|
247
|
+
* @returns A single element or list of elements
|
|
248
|
+
*/
|
|
249
|
+
findElOrEls(strategy: string, selector: string, mult: true, context?: any): Promise<Element[]>;
|
|
250
|
+
findElOrEls(strategy: string, selector: string, mult: false, context?: any): Promise<Element>;
|
|
251
|
+
|
|
252
|
+
/**
|
|
253
|
+
* This is a wrapper for {@linkcode findElOrEls} that validates locator strategies
|
|
254
|
+
* and implements the `appium:printPageSourceOnFindFailure` capability
|
|
255
|
+
*
|
|
256
|
+
* @param strategy - the locator strategy
|
|
257
|
+
* @param selector - the selector
|
|
258
|
+
* @param mult - whether or not we want to find multiple elements
|
|
259
|
+
* @param context - the element to use as the search context basis if desiredCapabilities
|
|
260
|
+
*
|
|
261
|
+
* @returns A single element or list of elements
|
|
262
|
+
*/
|
|
263
|
+
findElOrElsWithProcessing(
|
|
264
|
+
strategy: string,
|
|
265
|
+
selector: string,
|
|
266
|
+
mult: true,
|
|
267
|
+
context?: any,
|
|
268
|
+
): Promise<Element[]>;
|
|
269
|
+
findElOrElsWithProcessing(
|
|
270
|
+
strategy: string,
|
|
271
|
+
selector: string,
|
|
272
|
+
mult: false,
|
|
273
|
+
context?: any,
|
|
274
|
+
): Promise<Element>;
|
|
275
|
+
|
|
276
|
+
/**
|
|
277
|
+
* Get the current page/app source as HTML/XML
|
|
278
|
+
* @see {@link https://w3c.github.io/webdriver/#get-page-source}
|
|
279
|
+
*
|
|
280
|
+
* @returns The UI hierarchy in a platform-appropriate format (e.g., HTML for a web page)
|
|
281
|
+
*/
|
|
282
|
+
getPageSource(): Promise<string>;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
export interface ILogCommands {
|
|
286
|
+
/**
|
|
287
|
+
* Definition of the available log types
|
|
288
|
+
*/
|
|
289
|
+
supportedLogTypes: Readonly<LogDefRecord>;
|
|
290
|
+
|
|
291
|
+
/**
|
|
292
|
+
* Get available log types as a list of strings
|
|
293
|
+
*/
|
|
294
|
+
getLogTypes(): Promise<string[]>;
|
|
295
|
+
|
|
296
|
+
/**
|
|
297
|
+
* Get the log for a given log type.
|
|
298
|
+
*
|
|
299
|
+
* @param logType - Name/key of log type as defined in {@linkcode ILogCommands.supportedLogTypes}.
|
|
300
|
+
*/
|
|
301
|
+
getLog(logType: string): Promise<any>;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
/**
|
|
305
|
+
* A record of {@linkcode LogDef} objects, keyed by the log type name.
|
|
306
|
+
* Used in {@linkcode ILogCommands.supportedLogTypes}
|
|
307
|
+
*/
|
|
308
|
+
export type LogDefRecord = Record<string, LogDef>;
|
|
309
|
+
|
|
310
|
+
/**
|
|
311
|
+
* A definition of a log type
|
|
312
|
+
*/
|
|
313
|
+
export interface LogDef {
|
|
314
|
+
/**
|
|
315
|
+
* Description of the log type.
|
|
316
|
+
*
|
|
317
|
+
* The only place this is used is in error messages if the client provides an invalid log type
|
|
318
|
+
* via {@linkcode ILogCommands.getLog}.
|
|
319
|
+
*/
|
|
320
|
+
description: string;
|
|
321
|
+
/**
|
|
322
|
+
* Returns all the log data for the given type
|
|
323
|
+
*
|
|
324
|
+
* This implementation *should* drain, truncate or otherwise reset the log buffer.
|
|
325
|
+
*/
|
|
326
|
+
getter: (driver: any) => Promise<unknown> | unknown;
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
export interface ISettingsCommands<T extends object = object> {
|
|
330
|
+
/**
|
|
331
|
+
* Update the session's settings dictionary with a new settings object
|
|
332
|
+
*
|
|
333
|
+
* @param settings - A key-value map of setting names to values. Settings not named in the map
|
|
334
|
+
* will not have their value adjusted.
|
|
335
|
+
*/
|
|
336
|
+
updateSettings: (settings: T) => Promise<void>;
|
|
337
|
+
|
|
338
|
+
/**
|
|
339
|
+
* Get the current settings for the session
|
|
340
|
+
*
|
|
341
|
+
* @returns The settings object
|
|
342
|
+
*/
|
|
343
|
+
getSettings(): Promise<T>;
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
/**
|
|
347
|
+
* An interface which creates and deletes sessions.
|
|
348
|
+
*/
|
|
349
|
+
export interface ISessionHandler<
|
|
350
|
+
C extends Constraints = Constraints,
|
|
351
|
+
CreateResult = DefaultCreateSessionResult<C>,
|
|
352
|
+
DeleteResult = DefaultDeleteSessionResult,
|
|
353
|
+
SessionData extends StringRecord = StringRecord,
|
|
354
|
+
> {
|
|
355
|
+
/**
|
|
356
|
+
* Start a new automation session
|
|
357
|
+
* @see {@link https://w3c.github.io/webdriver/#new-session}
|
|
358
|
+
*
|
|
359
|
+
* @privateRemarks
|
|
360
|
+
* The shape of this method is strange because it used to support both JSONWP and W3C
|
|
361
|
+
* capabilities. This will likely change in the future to simplify.
|
|
362
|
+
*
|
|
363
|
+
* @param w3cCaps1 - the new session capabilities
|
|
364
|
+
* @param w3cCaps2 - another place the new session capabilities could be sent (typically left undefined)
|
|
365
|
+
* @param w3cCaps3 - another place the new session capabilities could be sent (typically left undefined)
|
|
366
|
+
* @param driverData - a list of DriverData objects representing other sessions running for this
|
|
367
|
+
* driver on the same Appium server. This information can be used to help ensure no conflict of
|
|
368
|
+
* resources
|
|
369
|
+
*
|
|
370
|
+
* @returns The capabilities object representing the created session
|
|
371
|
+
*/
|
|
372
|
+
createSession(
|
|
373
|
+
w3cCaps1: W3CDriverCaps<C>,
|
|
374
|
+
w3cCaps2?: W3CDriverCaps<C>,
|
|
375
|
+
w3cCaps3?: W3CDriverCaps<C>,
|
|
376
|
+
driverData?: DriverData[],
|
|
377
|
+
): Promise<CreateResult>;
|
|
378
|
+
|
|
379
|
+
/**
|
|
380
|
+
* Stop an automation session
|
|
381
|
+
* @see {@link https://w3c.github.io/webdriver/#delete-session}
|
|
382
|
+
*
|
|
383
|
+
* @param sessionId - the id of the session that is to be deleted
|
|
384
|
+
* @param driverData - the driver data for other currently-running sessions
|
|
385
|
+
*/
|
|
386
|
+
deleteSession(sessionId?: string, driverData?: DriverData[]): Promise<DeleteResult | void>;
|
|
387
|
+
|
|
388
|
+
/**
|
|
389
|
+
* Get the data for the current session
|
|
390
|
+
*
|
|
391
|
+
* @returns A session data object
|
|
392
|
+
*/
|
|
393
|
+
getSession(): Promise<SingularSessionData<C, SessionData>>;
|
|
394
|
+
|
|
395
|
+
/**
|
|
396
|
+
* Get the capabilities of the current session
|
|
397
|
+
*
|
|
398
|
+
* @returns A session capabilities object
|
|
399
|
+
*/
|
|
400
|
+
getAppiumSessionCapabilities(): Promise<SessionCapabilities<C>>;
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
/**
|
|
404
|
+
* @see {@linkcode ISessionHandler}
|
|
405
|
+
*/
|
|
406
|
+
export type DefaultCreateSessionResult<C extends Constraints> = [
|
|
407
|
+
sessionId: string,
|
|
408
|
+
capabilities: DriverCaps<C>,
|
|
409
|
+
];
|
|
410
|
+
|
|
411
|
+
/**
|
|
412
|
+
* @see {@linkcode ISessionHandler}
|
|
413
|
+
*/
|
|
414
|
+
export type DefaultDeleteSessionResult = void;
|
|
415
|
+
|
|
416
|
+
/**
|
|
417
|
+
* Custom session data for a driver.
|
|
418
|
+
*/
|
|
419
|
+
export type DriverData = Record<string, unknown>;
|
|
420
|
+
|
|
421
|
+
/**
|
|
422
|
+
* Data returned by {@linkcode ISessionHandler.getSession}.
|
|
423
|
+
*
|
|
424
|
+
* @typeParam C - The driver's capability constraints
|
|
425
|
+
* @typeParam T - Any extra data the driver stuffs in here
|
|
426
|
+
* @privateRemarks The content of this object looks implementation-specific and in practice is not well-defined. It's _possible_ to fully type this in the future.
|
|
427
|
+
*/
|
|
428
|
+
export type SingularSessionData<
|
|
429
|
+
C extends Constraints = Constraints,
|
|
430
|
+
T extends StringRecord = StringRecord,
|
|
431
|
+
> = DriverCaps<C> & {
|
|
432
|
+
events?: EventHistory;
|
|
433
|
+
error?: string;
|
|
434
|
+
} & T;
|
|
435
|
+
|
|
436
|
+
/**
|
|
437
|
+
* Data returned by `AppiumDriver.getAppiumSessions`
|
|
438
|
+
*
|
|
439
|
+
* @typeParam C - The driver's constraints
|
|
440
|
+
*/
|
|
441
|
+
export interface TimestampedMultiSessionData<C extends Constraints = Constraints> {
|
|
442
|
+
id: string;
|
|
443
|
+
created: number; // Unix timestamp in milliseconds
|
|
444
|
+
capabilities: DriverCaps<C>;
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
/**
|
|
448
|
+
* Data returned by {@linkcode ISessionCommands.getAppiumSessionCapabilities}.
|
|
449
|
+
*
|
|
450
|
+
* @typeParam C - The driver's constraints
|
|
451
|
+
* @typeParam T - Any extra data the driver stuffs in here
|
|
452
|
+
*/
|
|
453
|
+
export type SessionCapabilities<
|
|
454
|
+
C extends Constraints = Constraints,
|
|
455
|
+
T extends StringRecord = StringRecord,
|
|
456
|
+
> = {
|
|
457
|
+
capabilities: DriverCaps<C>;
|
|
458
|
+
} & T;
|
|
459
|
+
|
|
460
|
+
/**
|
|
461
|
+
* Interface for all commands expected to be implemented by BaseDriver.
|
|
462
|
+
*/
|
|
463
|
+
export type IImplementedCommands<
|
|
464
|
+
C extends Constraints = Constraints,
|
|
465
|
+
Settings extends StringRecord = StringRecord,
|
|
466
|
+
CreateResult = DefaultCreateSessionResult<C>,
|
|
467
|
+
DeleteResult = DefaultDeleteSessionResult,
|
|
468
|
+
SessionData extends StringRecord = StringRecord,
|
|
469
|
+
> = IBidiCommands
|
|
470
|
+
& ILogCommands
|
|
471
|
+
& IFindCommands
|
|
472
|
+
& ISettingsCommands<Settings>
|
|
473
|
+
& ITimeoutCommands
|
|
474
|
+
& IEventCommands
|
|
475
|
+
& IExecuteCommands
|
|
476
|
+
& ISessionHandler<C, CreateResult, DeleteResult, SessionData>;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Interface for all JSONWP commands proxied to the external driver.
|
|
3
|
+
*/
|
|
4
|
+
export interface IJSONWPCommands {
|
|
5
|
+
/**
|
|
6
|
+
* Get the device orientation
|
|
7
|
+
*
|
|
8
|
+
* @returns The orientation string
|
|
9
|
+
*/
|
|
10
|
+
getOrientation?(): Promise<string>;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Set the device orientation
|
|
14
|
+
*
|
|
15
|
+
* @param orientation - the orientation string
|
|
16
|
+
*/
|
|
17
|
+
setOrientation?(orientation: string): Promise<void>;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Get the virtual or real geographical location of a device
|
|
21
|
+
*
|
|
22
|
+
* @returns The location
|
|
23
|
+
*/
|
|
24
|
+
getGeoLocation?(): Promise<Location>;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Set the virtual geographical location of a device
|
|
28
|
+
*
|
|
29
|
+
* @param location - the location including latitude and longitude
|
|
30
|
+
* @returns The complete location
|
|
31
|
+
*/
|
|
32
|
+
setGeoLocation?(location: Partial<Location>): Promise<Location>;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export type Orientation = 'LANDSCAPE' | 'PORTRAIT';
|
|
36
|
+
|
|
37
|
+
export interface Location {
|
|
38
|
+
latitude: number;
|
|
39
|
+
longitude: number;
|
|
40
|
+
altitude?: number;
|
|
41
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Interface for all MJSONWP commands proxied to the external driver.
|
|
3
|
+
*/
|
|
4
|
+
export interface IMJSONWPCommands<Ctx = string> {
|
|
5
|
+
/**
|
|
6
|
+
* Get the currently active context
|
|
7
|
+
* @see {@link https://github.com/SeleniumHQ/mobile-spec/blob/master/spec-draft.md#webviews-and-other-contexts}
|
|
8
|
+
*
|
|
9
|
+
* @returns The context name
|
|
10
|
+
*/
|
|
11
|
+
getCurrentContext?(): Promise<Ctx | null>;
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Switch to a context by name
|
|
15
|
+
* @see {@link https://github.com/SeleniumHQ/mobile-spec/blob/master/spec-draft.md#webviews-and-other-contexts}
|
|
16
|
+
*
|
|
17
|
+
* @param name - the context name
|
|
18
|
+
*/
|
|
19
|
+
setContext?(name: string, ...args: any[]): Promise<void>;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Get the list of available contexts
|
|
23
|
+
* @see {@link https://github.com/SeleniumHQ/mobile-spec/blob/master/spec-draft.md#webviews-and-other-contexts}
|
|
24
|
+
*
|
|
25
|
+
* @returns The list of context names
|
|
26
|
+
*/
|
|
27
|
+
getContexts?(): Promise<Ctx[]>;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Get the network connection state of a device
|
|
31
|
+
* @see {@link https://github.com/SeleniumHQ/mobile-spec/blob/master/spec-draft.md#device-modes}
|
|
32
|
+
*
|
|
33
|
+
* @returns A number which is a bitmask representing categories like Data, Wifi, and Airplane
|
|
34
|
+
* mode status
|
|
35
|
+
*/
|
|
36
|
+
getNetworkConnection?(): Promise<number>;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Set the network connection of the device
|
|
40
|
+
* @see {@link https://github.com/SeleniumHQ/mobile-spec/blob/master/spec-draft.md#device-modes}
|
|
41
|
+
*
|
|
42
|
+
* @param type - the bitmask representing network state
|
|
43
|
+
* @returns A number which is a bitmask representing categories like Data, Wifi, and Airplane
|
|
44
|
+
* mode status
|
|
45
|
+
*/
|
|
46
|
+
setNetworkConnection?(type: number): Promise<number>;
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Get the current rotation state of the device
|
|
50
|
+
* @see {@link https://github.com/SeleniumHQ/mobile-spec/blob/master/spec-draft.md#device-rotation}
|
|
51
|
+
*
|
|
52
|
+
* @returns The Rotation object consisting of x, y, and z rotation values (0 <= n <= 360)
|
|
53
|
+
*/
|
|
54
|
+
getRotation?(): Promise<Rotation>;
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Set the device rotation state
|
|
58
|
+
* @see {@link https://github.com/SeleniumHQ/mobile-spec/blob/master/spec-draft.md#device-rotation}
|
|
59
|
+
*
|
|
60
|
+
* @param x - the degree to which the device is rotated around the x axis (0 <= x <= 360)
|
|
61
|
+
* @param y - the degree to which the device is rotated around the y axis (0 <= y <= 360)
|
|
62
|
+
* @param z - the degree to which the device is rotated around the z axis (0 <= z <= 360)
|
|
63
|
+
*/
|
|
64
|
+
setRotation?(x: number, y: number, z: number): Promise<void>;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export interface Rotation {
|
|
68
|
+
x: number;
|
|
69
|
+
y: number;
|
|
70
|
+
z: number;
|
|
71
|
+
}
|