@appium/base-driver 8.1.1 → 8.2.2

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.
Files changed (75) hide show
  1. package/build/lib/basedriver/capabilities.js +6 -6
  2. package/build/lib/basedriver/commands/find.js +1 -1
  3. package/build/lib/basedriver/commands/index.js +2 -4
  4. package/build/lib/basedriver/commands/log.js +1 -1
  5. package/build/lib/basedriver/commands/session.js +1 -1
  6. package/build/lib/basedriver/commands/timeout.js +1 -1
  7. package/build/lib/basedriver/desired-caps.js +1 -1
  8. package/build/lib/basedriver/device-settings.js +1 -1
  9. package/build/lib/basedriver/driver.js +5 -7
  10. package/build/lib/basedriver/helpers.js +5 -3
  11. package/build/lib/constants.js +1 -1
  12. package/build/lib/express/crash.js +1 -1
  13. package/build/lib/express/middleware.js +3 -3
  14. package/build/lib/express/server.js +1 -1
  15. package/build/lib/express/static.js +2 -2
  16. package/build/lib/express/websocket.js +3 -3
  17. package/build/lib/index.js +124 -0
  18. package/build/lib/jsonwp-status/status.js +1 -1
  19. package/build/lib/protocol/errors.js +6 -5
  20. package/build/lib/protocol/helpers.js +3 -3
  21. package/build/lib/protocol/index.js +31 -19
  22. package/build/lib/protocol/protocol.js +22 -11
  23. package/build/lib/protocol/routes.js +6 -12
  24. package/build/test/basedriver/capability-specs.js +10 -10
  25. package/build/test/basedriver/commands/event-specs.js +10 -10
  26. package/build/test/basedriver/driver-e2e-specs.js +3 -3
  27. package/build/test/basedriver/driver-e2e-tests.js +53 -256
  28. package/build/test/basedriver/driver-specs.js +3 -3
  29. package/build/test/basedriver/driver-tests.js +6 -6
  30. package/build/test/basedriver/helpers-e2e-specs.js +10 -4
  31. package/build/test/basedriver/index.js +4 -4
  32. package/build/test/basedriver/timeout-specs.js +7 -7
  33. package/build/test/basedriver/websockets-e2e-specs.js +11 -11
  34. package/build/test/express/server-e2e-specs.js +156 -0
  35. package/build/test/express/server-specs.js +151 -0
  36. package/build/test/express/static-specs.js +23 -0
  37. package/build/test/helpers.js +57 -0
  38. package/build/test/jsonwp-proxy/mock-request.js +93 -0
  39. package/build/test/jsonwp-proxy/protocol-converter-specs.js +173 -0
  40. package/build/test/jsonwp-proxy/proxy-e2e-specs.js +62 -0
  41. package/build/test/jsonwp-proxy/proxy-specs.js +299 -0
  42. package/build/test/jsonwp-proxy/url-specs.js +167 -0
  43. package/build/test/jsonwp-status/status-specs.js +36 -0
  44. package/build/test/protocol/errors-specs.js +388 -0
  45. package/build/test/protocol/fake-driver.js +168 -0
  46. package/build/test/protocol/helpers.js +27 -0
  47. package/build/test/protocol/protocol-e2e-specs.js +1242 -0
  48. package/build/test/protocol/routes-specs.js +82 -0
  49. package/build/test/protocol/validator-specs.js +151 -0
  50. package/index.d.ts +309 -44
  51. package/index.js +1 -62
  52. package/lib/basedriver/commands/index.js +0 -2
  53. package/lib/basedriver/driver.js +2 -22
  54. package/lib/basedriver/helpers.js +5 -4
  55. package/lib/index.js +62 -0
  56. package/lib/protocol/index.js +3 -1
  57. package/lib/protocol/protocol.js +18 -7
  58. package/lib/protocol/routes.js +1 -4
  59. package/package.json +8 -16
  60. package/test/basedriver/capability-specs.js +1 -1
  61. package/test/basedriver/commands/event-specs.js +1 -1
  62. package/test/basedriver/driver-e2e-specs.js +1 -1
  63. package/test/basedriver/driver-e2e-tests.js +66 -213
  64. package/test/basedriver/driver-specs.js +1 -1
  65. package/test/basedriver/driver-tests.js +3 -3
  66. package/test/basedriver/helpers-e2e-specs.js +9 -4
  67. package/test/basedriver/timeout-specs.js +1 -1
  68. package/test/basedriver/websockets-e2e-specs.js +7 -7
  69. package/build/index.js +0 -118
  70. package/build/lib/basedriver/commands/execute-child.js +0 -137
  71. package/build/lib/basedriver/commands/execute.js +0 -119
  72. package/build/test/basedriver/fixtures/custom-element-finder-bad.js +0 -12
  73. package/build/test/basedriver/fixtures/custom-element-finder.js +0 -36
  74. package/lib/basedriver/commands/execute-child.js +0 -132
  75. package/lib/basedriver/commands/execute.js +0 -126
package/index.d.ts CHANGED
@@ -1,9 +1,7 @@
1
- import { W3C_ELEMENT_KEY } from './lib/protocol/helpers'
2
-
3
1
  declare class BaseDriver {
4
2
  // class variables
5
3
  static baseVersion: string;
6
- static get argsConstraints(): {};
4
+ static newMethodMap?: MethodMap;
7
5
 
8
6
  constructor(opts?: {}, shouldValidateCaps?: boolean);
9
7
 
@@ -24,15 +22,15 @@ declare class BaseDriver {
24
22
  webLocatorStrategies: string[];
25
23
  settings: DeviceSettings;
26
24
  protocol?: string;
27
- supportedLogTypes: {[type: string]: LogType};
25
+ supportedLogTypes: { [type: string]: LogType };
28
26
 
29
27
  // getters/setters
30
28
  get driverData(): {};
31
29
  get isCommandsQueueEnabled(): boolean;
32
30
  get eventHistory(): {};
33
- get desiredCapConstraints(): {};
31
+ get desiredCapConstraints(): Constraints;
34
32
 
35
- set desiredCapConstraints(constraints: {});
33
+ set desiredCapConstraints(constraints: Constraints);
36
34
 
37
35
  // non-command methods
38
36
  onUnexpectedShutdown(handler: () => any): void;
@@ -46,7 +44,6 @@ declare class BaseDriver {
46
44
  executeCommand(cmd: string, ...args: any[]): Promise<any>;
47
45
  startUnexpectedShutdown(err?: Error): Promise<void>;
48
46
  validateLocatorStrategy(strategy: string, webContext?: boolean): void;
49
- reset(): Promise<void>;
50
47
  proxyActive(): boolean;
51
48
  getProxyAvoidList(): [string, RegExp][];
52
49
  canProxy(): boolean;
@@ -55,67 +52,335 @@ declare class BaseDriver {
55
52
  getManagedDrivers(): BaseDriver[];
56
53
  clearNewCommandTimeout(): Promise<void>;
57
54
  startNewCommandTimeout(): Promise<void>;
58
- implicitWaitForCondition(condition: () => Promise<any>): Promise<any>;
55
+ implicitWaitForCondition(condition: () => Promise<any>): Promise<unknown>;
59
56
 
60
- // commands
57
+ // Commands
58
+ findElOrEls(strategy: string, selector: string, mult: boolean, context: string): Promise<Element | Element[]>;
59
+ newCommandTimeout(ms: number): Promise<void>;
60
+ getLogTypes(): Promise<string[]>;
61
+ getLog(logType: string): Promise<{}[]>;
62
+
63
+ // WebDriver
61
64
  createSession(jwpCaps: {}, jwpReqCaps: {}, w3cCaps: {}): Promise<[string, {}]>;
62
- getSessions(): Promise<{id: string, capabilities: {}}>
63
- getSession(): Promise<{}>
64
65
  deleteSession(): Promise<void>;
65
- getSettings(): Promise<DeviceSettings>;
66
- updateSettings(newSettings: {}): Promise<DeviceSettings>;
67
- logCustomEvent(vendor: string, event: string): void;
68
- getLogEvents(type?: string | string[]): {};
69
- executeDriverScript(script: string, scriptType: string, timeout: number): Promise<{}>;
66
+ getSessions(): Promise<{ id: string; capabilities: {} }[]>;
67
+ getSession(): Promise<{}>;
68
+ getTimeouts(): Promise<Record<string, number>>;
69
+ timeouts(type: string, ms: number, script: number, pageLoad: number, implicit: number): Promise<void>;
70
+ setUrl?(url: string): Promise<void>;
71
+ getUrl?(): Promise<string>;
72
+ back?(): Promise<void>;
73
+ forward?(): Promise<void>;
74
+ refresh?(): Promise<void>;
75
+ title?(): Promise<string>;
76
+ getWindowHandle?(): Promise<string>;
77
+ closeWindow?(): Promise<string[]>;
78
+ setWindow?(handle: string): Promise<void>;
79
+ getWindowHandles?(): Promise<string[]>;
80
+ setFrame?(id: null | number | string): Promise<void>;
81
+ getWindowRect?(): Promise<Rect>;
82
+ setWindowRect?(x: number, y: number, width: number, height: number): Promise<Rect>;
83
+ maximizeWindow?(): Promise<Rect>;
84
+ minimizeWindow?(): Promise<Rect>;
85
+ fullScreenWindow?(): Promise<Rect>;
86
+ active?(): Promise<Element>;
70
87
  findElement(strategy: string, selector: string): Promise<Element>;
71
88
  findElements(strategy: string, selector: string): Promise<Element[]>;
72
-
73
89
  findElementFromElement(strategy: string, selector: string, elementId: string): Promise<Element>;
74
90
  findElementsFromElement(strategy: string, selector: string, elementId: string): Promise<Element[]>;
75
- findElOrEls(strategy: string, selector: string, mult: boolean, context: string): Promise<Element>;
76
- getLogTypes(): Promise<string[]>
77
- getLog(logType: string): Promise<{}[]>
78
- timeouts(type: string, ms: number, script: number, pageLoad: number, implicit: number): Promise<void>;
79
- getTimeouts(): Promise<{command: number, implicit: number}>;
91
+ elementSelected?(elementId: string): Promise<boolean>;
92
+ getAttribute?(name: string, elementId: string): Promise<string | null>;
93
+ getProperty?(name: string, elementId: string): Promise<string | null>;
94
+ getCssProperty?(name: string, elementId: string): Promise<string>;
95
+ getText?(elementId: string): Promise<string>;
96
+ getName?(elementId: string): Promise<string>;
97
+ getElementRect?(elementId: string): Promise<Rect>;
98
+ elementEnabled?(elementId: string): Promise<boolean>;
99
+ elementDisplayed?(elementId: string): Promise<boolean>;
100
+ click?(elementId: string): Promise<void>;
101
+ clear?(elementId: string): Promise<void>;
102
+ setValue?(text: string, elementId: string): Promise<void>;
103
+ getPageSource?(): Promise<string>;
104
+ execute?(script: string, args: unknown[]): Promise<unknown>;
105
+ executeAsync?(script: string, args: unknown[]): Promise<unknown>;
106
+ getCookies?(): Promise<Cookie[]>;
107
+ getCookie?(name: string): Promise<Cookie>;
108
+ setCookie?(cookie: Cookie): Promise<void>;
109
+ deleteCookie?(name: string): Promise<void>;
110
+ deleteCookies?(): Promise<void>;
111
+ performActions?(actions: Actions[]): Promise<void>;
112
+ releaseActions?(): Promise<void>;
113
+ postDismissAlert?(): Promise<void>;
114
+ postAcceptAlert?(): Promise<void>;
115
+ getAlertText?(): Promise<string | null>;
116
+ setAlertText?(text: string): Promise<void>;
117
+ getScreenshot?(): Promise<string>;
118
+ getElementScreenshot?(elementId: string): Promise<string>;
119
+
120
+ // Appium W3C WebDriver Extension
121
+ mobileShake?(): Promise<void>;
122
+ getDeviceTime?(format?: string): Promise<string>;
123
+ lock?(seconds?: number): Promise<void>;
124
+ unlock?(): Promise<void>;
125
+ isLocked?(): Promise<boolean>;
126
+ startRecordingScreen?(options?: ScreenRecordOptions): Promise<void>;
127
+ stopRecordingScreen?(options?: ScreenRecordOptions): Promise<string>;
128
+ getPerformanceDataTypes?(): Promise<string[]>;
129
+ getPerformanceData?(packageName: string, dataType: string, dataReadTimeout?: number): Promise<string[]>;
130
+ pressKeyCode?(keycode: number, metastate?: number, flags?: number): Promise<void>;
131
+ longPressKeyCode?(keycode: number, metastate?: number, flags?: number): Promise<void>;
132
+ fingerprint?(fingerprintId: number): Promise<void>;
133
+ sendSMS?(phoneNumber: string, message: string): Promise<void>;
134
+ gsmCall?(phoneNumber: string, action: string): Promise<void>;
135
+ gsmSignal?(signalStrength: string): Promise<void>;
136
+ gsmVoice?(state: string): Promise<void>;
137
+ powerCapacity?(percent: number): Promise<void>;
138
+ powerAC?(state: string): Promise<void>;
139
+ networkSpeed?(netspeed: string): Promise<void>;
140
+ keyevent?(keycode: string, metastate?: string): Promise<void>;
141
+ mobileRotation?(x: number, y: number, radius: number, rotation: number, touchCount: number, duration: string, elementId?: string): Promise<void>;
142
+ getCurrentActivity?(): Promise<string>;
143
+ getCurrentPackage?(): Promise<string>;
144
+ installApp?(appPath: string, options?: unknown): Promise<void>;
145
+ activateApp?(appId: string, options?: unknown): Promise<void>;
146
+ removeApp?(appId: string, options?: unknown): Promise<void>;
147
+ terminateApp?(appId: string, options?: unknown): Promise<void>;
148
+ isAppInstalled?(appId: string): Promise<boolean>;
149
+ queryAppState?(appId: string): Promise<number>;
150
+ hideKeyboard?(strategy?: string, key?: string, keyCode?: string, keyName?: string): Promise<void>;
151
+ isKeyboardShown?(): Promise<boolean>;
152
+ pushFile?(path: string, data: string): Promise<void>;
153
+ pullFile?(path: string): Promise<string>;
154
+ pullFolder?(path: string): Promise<string>;
155
+ toggleFlightMode?(): Promise<void>;
156
+ toggleData?(): Promise<void>;
157
+ toggleWiFi?(): Promise<void>;
158
+ toggleLocationServices?(): Promise<void>;
159
+ openNotifications?(): Promise<void>;
160
+ startActivity?(appPackage: string, appActivity: string, appWaitPackage?: string, appWaitActivity?: string, intentAction?: string, intentCategory?: string, intentFlags?: string, optionalIntentArguments?: string, dontStopAppOnReset?: boolean): Promise<void>;
161
+ getSystemBars?(): Promise<unknown[]>;
162
+ getDisplayDensity?(): Promise<number>;
163
+ touchId?(match: boolean): Promise<void>;
164
+ toggleEnrollTouchId?(enabled: boolean): Promise<void>;
165
+ launchApp?(): Promise<void>;
166
+ closeApp?(): Promise<void>;
167
+ reset(): Promise<void>;
168
+ background?(seconds: null | number): Promise<void>;
169
+ endCoverage?(intent: string, path: string): Promise<void>;
170
+ getStrings?(language?: string, stringFile?: string): Promise<Record<string, unknown>>;
171
+ setValueImmediate?(value: string, elementId: string): Promise<void>;
172
+ replaceValue?(value: string, elementId: string): Promise<void>;
173
+ updateSettings(newSettings: Record<string, unknown>): Promise<void>;
174
+ getSettings(): Promise<Record<string, unknown>>;
175
+ receiveAsyncResponse?(response: unknown): Promise<void>;
176
+ getLogEvents(type?: string | string[]): {};
177
+ logCustomEvent(vendor: string, event: string): void;
178
+ setClipboard?(content: string, contentType?: string, label?: string): Promise<void>;
179
+ getClipboard?(contentType?: string): Promise<string>;
180
+
181
+ // JSONWP
182
+ asyncScriptTimeout?(ms: number): Promise<void>;
80
183
  implicitWait(ms: number): Promise<void>;
81
- newCommandTimeout(ms: number): Promise<void>;
184
+ getWindowSize?(): Promise<Size>;
185
+ getLocation?(elementId: string): Promise<Position>;
186
+ getLocationInView?(elementId: string): Promise<Position>;
187
+ getSize?(elementId: string): Promise<Size>;
188
+ equalsElement?(elementId: string, otherElementId: string): Promise<boolean>;
189
+ submit?(elementId: string): Promise<void>;
190
+ keys?(value: string[]): Promise<void>;
191
+ availableIMEEngines?(): Promise<string[]>;
192
+ getActiveIMEEngine?(): Promise<string>;
193
+ isIMEActivated?(): Promise<boolean>;
194
+ deactivateIMEEngine?(): Promise<void>;
195
+ activateIMEEngine?(engine: string): Promise<void>;
196
+ getOrientation?(): Promise<string>;
197
+ setOrientation?(orientation: string): Promise<void>;
198
+ moveTo?(element?: null | string, xOffset?: number, yOffset?: number): Promise<void>;
199
+ buttonDown?(button?: number): Promise<void>;
200
+ buttonUp?(button?: number): Promise<void>;
201
+ clickCurrent?(button?: number): Promise<void>;
202
+ doubleClick?(): Promise<void>;
203
+ touchDown?(x: number, y: number): Promise<void>;
204
+ touchUp?(x: number, y: number): Promise<void>;
205
+ touchMove?(x: number, y: number): Promise<void>;
206
+ touchLongClick?(elementId: string): Promise<void>;
207
+ flick?(element?: string, xSpeed?: number, ySpeed?: number, xOffset?: number, yOffset?: number, speed?: number): Promise<void>;
208
+ getGeoLocation?(): Promise<Location>;
209
+ setGeoLocation?(location: Partial<Location>): Promise<void>;
210
+
211
+ // MJSONWIRE
212
+ getCurrentContext?(): Promise<string | null>;
213
+ setContext?(name: string): Promise<void>;
214
+ getContexts?(): Promise<string[]>;
215
+ getPageIndex?(elementId: string): Promise<string>;
216
+ getNetworkConnection?(): Promise<number>;
217
+ setNetworkConnection?(type: number): Promise<void>;
218
+ performTouch?(actions: unknown): Promise<void>;
219
+ performMultiAction?(actions: unknown, elementId: string): Promise<void>;
220
+ getRotation?(): Promise<Rotation>;
221
+ setRotation?(x: number, y: number, z: number): Promise<void>;
222
+
223
+ // Chromium DevTools
224
+ executeCdp?(cmd: string, params: unknown): Promise<unknown>;
225
+
226
+ // Web Authentication
227
+ addVirtualAuthenticator?(protocol: string, transport: string, hasResidentKey?: boolean, hasUserVerification?: boolean, isUserConsenting?: boolean, isUserVerified?: boolean): Promise<void>;
228
+ removeVirtualAuthenticator?(): Promise<void>;
229
+ addAuthCredential?(credentialId: string, isResidentCredential: boolean, rpId: string, privateKey: string, userHandle?: string, signCount?: number): Promise<void>;
230
+ getAuthCredential?(): Promise<Credential[]>;
231
+ removeAllAuthCredentials?(): Promise<void>;
232
+ removeAuthCredential?(): Promise<void>;
233
+ setUserAuthVerified?(isUserVerified: boolean): Promise<void>;
82
234
  }
83
235
 
236
+ declare type MethodMap = {
237
+ [path: string]: {
238
+ [method: string]: {
239
+ command?: string;
240
+ neverProxy?: boolean;
241
+ payloadParams?: {
242
+ wrap?: string;
243
+ unwrap?: string;
244
+ required?: string[] | string[][];
245
+ optional?: string[] | string[][];
246
+ validate?: (obj: any, protocol: string) => any;
247
+ makeArgs?: (obj: any) => any;
248
+ };
249
+ };
250
+ };
251
+ };
252
+
253
+ declare type Constraints = {
254
+ [key: string]: {
255
+ presence?: boolean;
256
+ isString?: boolean;
257
+ isNumber?: boolean;
258
+ isBoolean?: boolean;
259
+ isObject?: boolean;
260
+ isArray?: boolean;
261
+ deprecated?: boolean;
262
+ inclusion?: any[];
263
+ };
264
+ };
265
+
84
266
  declare type DriverOpts = {
85
- tmpDir: string
86
- [key: string]: any
87
- }
267
+ tmpDir: string;
268
+ [key: string]: any;
269
+ };
88
270
 
89
271
  declare type Element = {
90
- 'element-6066-11e4-a52e-4f735466cecf': string
91
- }
272
+ 'element-6066-11e4-a52e-4f735466cecf': string;
273
+ };
92
274
 
93
275
  declare interface DriverHelpers {
94
- configureApp: (
95
- app: string,
96
- supportedAppExtensions: string[]
97
- ) => Promise<string>;
276
+ configureApp: (app: string, supportedAppExtensions: string[]) => Promise<string>;
98
277
  isPackageOrBundle: (app: string) => boolean;
99
- duplicateKeys: <T>(
100
- input: T,
101
- firstKey: string,
102
- secondKey: string
103
- ) => T;
104
- parseCapsArray: (cap: string|string[]) => string[]
278
+ duplicateKeys: <T>(input: T, firstKey: string, secondKey: string) => T;
279
+ parseCapsArray: (cap: string | string[]) => string[];
105
280
  }
106
281
 
107
- declare type SettingsUpdater = (prop: string, newValue: {}, curValue: {}) => Promise<void>;
282
+ declare type SettingsUpdater = (
283
+ prop: string,
284
+ newValue: {},
285
+ curValue: {},
286
+ ) => Promise<void>;
108
287
 
109
288
  declare class DeviceSettings {
110
289
  constructor(defaultSettings: {}, onSettingsUpdate: SettingsUpdater);
111
290
  update(newSettings: {}): Promise<void>;
112
- getSettings(): DeviceSettings;
291
+ getSettings(): Record<string, unknown>;;
113
292
  }
114
293
 
115
294
  declare type LogType = {
116
- description: string
117
- getter: (driver: BaseDriver) => Promise<{}[]>
118
- }
295
+ description: string;
296
+ getter: (driver: BaseDriver) => Promise<{}[]>;
297
+ };
298
+
299
+ // WebDriver
300
+
301
+ declare type Rect = {
302
+ x: number;
303
+ y: number;
304
+ width: number;
305
+ height: number;
306
+ };
307
+
308
+ declare type Cookie = {
309
+ name: string;
310
+ value: string;
311
+ path?: string;
312
+ domain?: string;
313
+ secure?: boolean;
314
+ httpOnly?: boolean;
315
+ expiry?: number;
316
+ sameSite?: 'Lax' | 'Strict';
317
+ };
318
+
319
+ declare type Actions = {
320
+ type?: string;
321
+ actions: Action[];
322
+ parameters?: {
323
+ pointerType?: string;
324
+ };
325
+ };
326
+
327
+ declare type Action = {
328
+ duration?: number;
329
+ type: string;
330
+ value?: string;
331
+ x?: number;
332
+ y?: number;
333
+ button?: number;
334
+ origin?: string;
335
+ };
336
+
337
+ // Appium W3C WebDriver Extension
338
+
339
+ declare type ScreenRecordOptions = {
340
+ remotePath?: string;
341
+ username?: string;
342
+ password?: string;
343
+ method?: string;
344
+ forceRestart?: boolean;
345
+ timeLimit?: string;
346
+ videoType?: string;
347
+ videoQuality?: string;
348
+ videoFps?: string;
349
+ videoScale?: string;
350
+ bitRate?: string;
351
+ videoSize?: string;
352
+ bugReport?: string;
353
+ };
354
+
355
+ // JSONWP
356
+
357
+ declare type Size = Pick<Rect, 'width' | 'height'>;
358
+
359
+ declare type Position = Pick<Rect, 'x' | 'y'>;
360
+
361
+ declare type Location = {
362
+ latitude: number;
363
+ longitude: number;
364
+ altitude: number;
365
+ };
366
+
367
+ declare type Rotation = {
368
+ x: number;
369
+ y: number;
370
+ z: number;
371
+ };
372
+
373
+ // Web Authentication
374
+
375
+ declare type Credential = {
376
+ credentialId: string;
377
+ isResidentCredential: boolean;
378
+ rpId: string;
379
+ privateKey: string;
380
+ userHandle?: string;
381
+ signCount: number;
382
+ largeBlob?: string;
383
+ };
119
384
 
120
- export { BaseDriver, DriverHelpers, DriverOpts, Element, LogType };
385
+ export { BaseDriver, DriverHelpers, DriverOpts, Element, LogType, MethodMap, Constraints, SettingsUpdater, DeviceSettings, Rect, Cookie, Actions, Action, ScreenRecordOptions, Size, Position, Location, Rotation, Credential };
121
386
  export default BaseDriver;
package/index.js CHANGED
@@ -1,62 +1 @@
1
- // transpile:main
2
-
3
- // BaseDriver exports
4
- import * as driver from './lib/basedriver/driver';
5
- import * as deviceSettings from './lib/basedriver/device-settings';
6
-
7
- const { BaseDriver } = driver;
8
- const { DeviceSettings, BASEDRIVER_HANDLED_SETTINGS } = deviceSettings;
9
-
10
- export { BaseDriver, DeviceSettings, BASEDRIVER_HANDLED_SETTINGS };
11
- export default BaseDriver;
12
-
13
-
14
- // MJSONWP exports
15
- import * as protocol from './lib/protocol';
16
- import {
17
- DEFAULT_BASE_PATH, PROTOCOLS
18
- } from './lib/constants';
19
-
20
- const {
21
- Protocol, routeConfiguringFunction, errors, isErrorType,
22
- errorFromMJSONWPStatusCode, errorFromW3CJsonCode, ALL_COMMANDS, METHOD_MAP,
23
- routeToCommandName, NO_SESSION_ID_COMMANDS, isSessionCommand,
24
- normalizeBasePath, determineProtocol
25
- } = protocol;
26
-
27
- export {
28
- Protocol, routeConfiguringFunction, errors, isErrorType, PROTOCOLS,
29
- errorFromMJSONWPStatusCode, errorFromW3CJsonCode, determineProtocol,
30
- errorFromMJSONWPStatusCode as errorFromCode, ALL_COMMANDS, METHOD_MAP,
31
- routeToCommandName, NO_SESSION_ID_COMMANDS, isSessionCommand,
32
- DEFAULT_BASE_PATH, normalizeBasePath
33
- };
34
-
35
- // Express exports
36
- import * as staticIndex from './lib/express/static';
37
- const { STATIC_DIR } = staticIndex;
38
- export { STATIC_DIR };
39
-
40
- import * as serverIndex from './lib/express/server';
41
- const { server } = serverIndex;
42
- export { server };
43
-
44
- // jsonwp-proxy exports
45
- import * as proxyIndex from './lib/jsonwp-proxy/proxy';
46
- const { JWProxy } = proxyIndex;
47
- export { JWProxy };
48
-
49
- // jsonwp-status exports
50
- import * as statusIndex from './lib/jsonwp-status/status';
51
- const { codes: statusCodes, getSummaryByCode } = statusIndex;
52
- export { statusCodes, getSummaryByCode };
53
-
54
- // W3C capabilities parser
55
- import * as caps from './lib/basedriver/capabilities';
56
- const { processCapabilities, isStandardCap, validateCaps } = caps;
57
- export { processCapabilities, isStandardCap, validateCaps };
58
-
59
- // Web socket helpers
60
- import * as ws from './lib/express/websocket';
61
- const { DEFAULT_WS_PATHNAME_PREFIX } = ws;
62
- export { DEFAULT_WS_PATHNAME_PREFIX };
1
+ module.exports = require('./build/lib');
@@ -3,7 +3,6 @@ import settingsCmds from './settings';
3
3
  import timeoutCmds from './timeout';
4
4
  import findCmds from './find';
5
5
  import logCmds from './log';
6
- import executeCmds from './execute';
7
6
  import eventCmds from './event';
8
7
 
9
8
 
@@ -16,7 +15,6 @@ Object.assign(
16
15
  timeoutCmds,
17
16
  findCmds,
18
17
  logCmds,
19
- executeCmds,
20
18
  eventCmds,
21
19
  // add other command types here
22
20
  );
@@ -38,27 +38,6 @@ class BaseDriver extends Protocol {
38
38
  */
39
39
  static baseVersion = BASEDRIVER_VER;
40
40
 
41
- /**
42
- * Override this getter in child driver classes
43
- * if you'd like to expose any command line arguments.
44
- * These arguments take precedence over any opts.
45
- *
46
- * @returns {Object} The map which represents constraints over
47
- * supported command line arguments. The map should look similar
48
- * to the desired capabilities constraints one, for example:
49
- * {
50
- * webkitDebugProxyPort: {
51
- * isNumber: true
52
- * },
53
- * wdaLocalPort: {
54
- * isNumber: true
55
- * },
56
- * }
57
- */
58
- static get argsConstraints () {
59
- return {};
60
- }
61
-
62
41
  constructor (opts = {}, shouldValidateCaps = true) {
63
42
  super();
64
43
 
@@ -327,6 +306,7 @@ class BaseDriver extends Protocol {
327
306
  async executeCommand (cmd, ...args) {
328
307
  // get start time for this command, and log in special cases
329
308
  let startTime = Date.now();
309
+
330
310
  if (cmd === 'createSession') {
331
311
  // If creating a session determine if W3C or MJSONWP protocol was requested and remember the choice
332
312
  this.protocol = determineProtocol(...args);
@@ -362,7 +342,7 @@ class BaseDriver extends Protocol {
362
342
  unexpectedShutdownListener = null;
363
343
  }
364
344
  });
365
- const res = this.isCommandsQueueEnabled && cmd !== 'executeDriverScript'
345
+ const res = this.isCommandsQueueEnabled
366
346
  ? await this.commandsQueueGuard.acquire(BaseDriver.name, commandExecutor)
367
347
  : await commandExecutor();
368
348
 
@@ -2,7 +2,7 @@ import _ from 'lodash';
2
2
  import path from 'path';
3
3
  import url from 'url';
4
4
  import logger from './logger';
5
- import { system, tempDir, fs, util, zip, net, timing } from '@appium/support';
5
+ import { tempDir, fs, util, zip, net, timing } from '@appium/support';
6
6
  import LRU from 'lru-cache';
7
7
  import AsyncLock from 'async-lock';
8
8
  import axios from 'axios';
@@ -322,15 +322,16 @@ async function unzipApp (zipPath, dstRoot, supportedAppExtensions) {
322
322
  try {
323
323
  logger.debug(`Unzipping '${zipPath}'`);
324
324
  const timer = new timing.Timer().start();
325
+ const useSystemUnzipEnv = process.env.APPIUM_PREFER_SYSTEM_UNZIP;
326
+ const useSystemUnzip = _.isEmpty(useSystemUnzipEnv)
327
+ || !['0', 'false'].includes(_.toLower(useSystemUnzipEnv));
325
328
  /**
326
329
  * Attempt to use use the system `unzip` (e.g., `/usr/bin/unzip`) due
327
330
  * to the significant performance improvement it provides over the native
328
331
  * JS "unzip" implementation.
329
332
  * @type {import('@appium/support/lib/zip').ExtractAllOptions}
330
333
  */
331
- const extractionOpts = {
332
- useSystemUnzip: !system.isWindows(),
333
- };
334
+ const extractionOpts = {useSystemUnzip};
334
335
  // https://github.com/appium/appium/issues/14100
335
336
  if (path.extname(zipPath) === IPA_EXT) {
336
337
  logger.debug(`Enforcing UTF-8 encoding on the extracted file names for '${path.basename(zipPath)}'`);
package/lib/index.js ADDED
@@ -0,0 +1,62 @@
1
+ // transpile:main
2
+
3
+ // BaseDriver exports
4
+ import * as driver from './basedriver/driver';
5
+ import * as deviceSettings from './basedriver/device-settings';
6
+
7
+ const { BaseDriver } = driver;
8
+ const { DeviceSettings, BASEDRIVER_HANDLED_SETTINGS } = deviceSettings;
9
+
10
+ export { BaseDriver, DeviceSettings, BASEDRIVER_HANDLED_SETTINGS };
11
+ export default BaseDriver;
12
+
13
+
14
+ // MJSONWP exports
15
+ import * as protocol from './protocol';
16
+ import {
17
+ DEFAULT_BASE_PATH, PROTOCOLS
18
+ } from './constants';
19
+
20
+ const {
21
+ Protocol, routeConfiguringFunction, errors, isErrorType,
22
+ errorFromMJSONWPStatusCode, errorFromW3CJsonCode, ALL_COMMANDS, METHOD_MAP,
23
+ routeToCommandName, NO_SESSION_ID_COMMANDS, isSessionCommand,
24
+ normalizeBasePath, determineProtocol, CREATE_SESSION_COMMAND, DELETE_SESSION_COMMAND,
25
+ } = protocol;
26
+
27
+ export {
28
+ Protocol, routeConfiguringFunction, errors, isErrorType, PROTOCOLS,
29
+ errorFromMJSONWPStatusCode, errorFromW3CJsonCode, determineProtocol,
30
+ errorFromMJSONWPStatusCode as errorFromCode, ALL_COMMANDS, METHOD_MAP,
31
+ routeToCommandName, NO_SESSION_ID_COMMANDS, isSessionCommand,
32
+ DEFAULT_BASE_PATH, normalizeBasePath, CREATE_SESSION_COMMAND, DELETE_SESSION_COMMAND
33
+ };
34
+
35
+ // Express exports
36
+ import * as staticIndex from './express/static';
37
+ const { STATIC_DIR } = staticIndex;
38
+ export { STATIC_DIR };
39
+
40
+ import * as serverIndex from './express/server';
41
+ const { server } = serverIndex;
42
+ export { server };
43
+
44
+ // jsonwp-proxy exports
45
+ import * as proxyIndex from './jsonwp-proxy/proxy';
46
+ const { JWProxy } = proxyIndex;
47
+ export { JWProxy };
48
+
49
+ // jsonwp-status exports
50
+ import * as statusIndex from './jsonwp-status/status';
51
+ const { codes: statusCodes, getSummaryByCode } = statusIndex;
52
+ export { statusCodes, getSummaryByCode };
53
+
54
+ // W3C capabilities parser
55
+ import * as caps from './basedriver/capabilities';
56
+ const { processCapabilities, isStandardCap, validateCaps } = caps;
57
+ export { processCapabilities, isStandardCap, validateCaps };
58
+
59
+ // Web socket helpers
60
+ import * as ws from './express/websocket';
61
+ const { DEFAULT_WS_PATHNAME_PREFIX } = ws;
62
+ export { DEFAULT_WS_PATHNAME_PREFIX };
@@ -1,7 +1,8 @@
1
1
  // transpile:main
2
2
 
3
3
  import {
4
- Protocol, isSessionCommand, routeConfiguringFunction, determineProtocol
4
+ Protocol, isSessionCommand, routeConfiguringFunction, determineProtocol,
5
+ CREATE_SESSION_COMMAND, DELETE_SESSION_COMMAND,
5
6
  } from './protocol';
6
7
  import {
7
8
  NO_SESSION_ID_COMMANDS, ALL_COMMANDS, METHOD_MAP,
@@ -15,4 +16,5 @@ export {
15
16
  Protocol, routeConfiguringFunction, errors, isErrorType,
16
17
  errorFromMJSONWPStatusCode, errorFromW3CJsonCode, ALL_COMMANDS, METHOD_MAP,
17
18
  routeToCommandName, NO_SESSION_ID_COMMANDS, isSessionCommand, determineProtocol,
19
+ CREATE_SESSION_COMMAND, DELETE_SESSION_COMMAND,
18
20
  };