appium-uiautomator2-driver 2.42.2 → 2.43.1

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 (114) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/build/lib/commands/actions.d.ts +22 -1
  3. package/build/lib/commands/actions.d.ts.map +1 -1
  4. package/build/lib/commands/actions.js +30 -62
  5. package/build/lib/commands/actions.js.map +1 -1
  6. package/build/lib/commands/alert.d.ts +28 -1
  7. package/build/lib/commands/alert.d.ts.map +1 -1
  8. package/build/lib/commands/alert.js +42 -23
  9. package/build/lib/commands/alert.js.map +1 -1
  10. package/build/lib/commands/app-management.d.ts +19 -0
  11. package/build/lib/commands/app-management.d.ts.map +1 -0
  12. package/build/lib/commands/app-management.js +45 -0
  13. package/build/lib/commands/app-management.js.map +1 -0
  14. package/build/lib/commands/app-strings.d.ts +9 -0
  15. package/build/lib/commands/app-strings.d.ts.map +1 -1
  16. package/build/lib/commands/app-strings.js +11 -79
  17. package/build/lib/commands/app-strings.js.map +1 -1
  18. package/build/lib/commands/battery.d.ts +7 -0
  19. package/build/lib/commands/battery.d.ts.map +1 -1
  20. package/build/lib/commands/battery.js +14 -20
  21. package/build/lib/commands/battery.js.map +1 -1
  22. package/build/lib/commands/element.d.ts +100 -1
  23. package/build/lib/commands/element.d.ts.map +1 -1
  24. package/build/lib/commands/element.js +175 -125
  25. package/build/lib/commands/element.js.map +1 -1
  26. package/build/lib/commands/execute.d.ts +25 -0
  27. package/build/lib/commands/execute.d.ts.map +1 -0
  28. package/build/lib/commands/execute.js +109 -0
  29. package/build/lib/commands/execute.js.map +1 -0
  30. package/build/lib/commands/find.d.ts +10 -0
  31. package/build/lib/commands/find.d.ts.map +1 -1
  32. package/build/lib/commands/find.js +25 -27
  33. package/build/lib/commands/find.js.map +1 -1
  34. package/build/lib/commands/gestures.d.ts +103 -1
  35. package/build/lib/commands/gestures.d.ts.map +1 -1
  36. package/build/lib/commands/gestures.js +202 -173
  37. package/build/lib/commands/gestures.js.map +1 -1
  38. package/build/lib/commands/keyboard.d.ts +47 -0
  39. package/build/lib/commands/keyboard.d.ts.map +1 -0
  40. package/build/lib/commands/keyboard.js +92 -0
  41. package/build/lib/commands/keyboard.js.map +1 -0
  42. package/build/lib/commands/misc.d.ts +48 -0
  43. package/build/lib/commands/misc.d.ts.map +1 -0
  44. package/build/lib/commands/misc.js +75 -0
  45. package/build/lib/commands/misc.js.map +1 -0
  46. package/build/lib/commands/navigation.d.ts +20 -0
  47. package/build/lib/commands/navigation.d.ts.map +1 -0
  48. package/build/lib/commands/navigation.js +35 -0
  49. package/build/lib/commands/navigation.js.map +1 -0
  50. package/build/lib/commands/screenshot.d.ts +24 -1
  51. package/build/lib/commands/screenshot.d.ts.map +1 -1
  52. package/build/lib/commands/screenshot.js +87 -64
  53. package/build/lib/commands/screenshot.js.map +1 -1
  54. package/build/lib/commands/touch.d.ts +81 -0
  55. package/build/lib/commands/touch.d.ts.map +1 -1
  56. package/build/lib/commands/touch.js +158 -41
  57. package/build/lib/commands/touch.js.map +1 -1
  58. package/build/lib/commands/viewport.d.ts +37 -1
  59. package/build/lib/commands/viewport.d.ts.map +1 -1
  60. package/build/lib/commands/viewport.js +80 -36
  61. package/build/lib/commands/viewport.js.map +1 -1
  62. package/build/lib/driver.d.ts +94 -24
  63. package/build/lib/driver.d.ts.map +1 -1
  64. package/build/lib/driver.js +114 -28
  65. package/build/lib/driver.js.map +1 -1
  66. package/build/lib/helpers.d.ts +12 -6
  67. package/build/lib/helpers.d.ts.map +1 -1
  68. package/build/lib/helpers.js +18 -18
  69. package/build/lib/helpers.js.map +1 -1
  70. package/build/lib/method-map.d.ts +0 -23
  71. package/build/lib/method-map.d.ts.map +1 -1
  72. package/build/lib/uiautomator2.js +3 -3
  73. package/build/lib/uiautomator2.js.map +1 -1
  74. package/build/tsconfig.tsbuildinfo +1 -1
  75. package/lib/commands/actions.js +37 -114
  76. package/lib/commands/alert.js +51 -37
  77. package/lib/commands/app-management.js +42 -0
  78. package/lib/commands/app-strings.js +9 -89
  79. package/lib/commands/battery.js +16 -26
  80. package/lib/commands/element.js +235 -214
  81. package/lib/commands/execute.js +120 -0
  82. package/lib/commands/find.js +31 -37
  83. package/lib/commands/gestures.js +252 -234
  84. package/lib/commands/keyboard.js +103 -0
  85. package/lib/commands/misc.js +106 -0
  86. package/lib/commands/navigation.js +31 -0
  87. package/lib/commands/screenshot.js +96 -77
  88. package/lib/commands/touch.js +190 -48
  89. package/lib/commands/viewport.js +100 -50
  90. package/lib/driver.ts +225 -36
  91. package/lib/helpers.js +15 -22
  92. package/lib/uiautomator2.js +3 -3
  93. package/npm-shrinkwrap.json +34 -34
  94. package/package.json +2 -2
  95. package/build/lib/commands/general.d.ts +0 -4
  96. package/build/lib/commands/general.d.ts.map +0 -1
  97. package/build/lib/commands/general.js +0 -214
  98. package/build/lib/commands/general.js.map +0 -1
  99. package/build/lib/commands/index.d.ts +0 -2
  100. package/build/lib/commands/index.d.ts.map +0 -1
  101. package/build/lib/commands/index.js +0 -14
  102. package/build/lib/commands/index.js.map +0 -1
  103. package/build/lib/commands/mixins.d.ts +0 -87
  104. package/build/lib/commands/mixins.d.ts.map +0 -1
  105. package/build/lib/commands/mixins.js +0 -26
  106. package/build/lib/commands/mixins.js.map +0 -1
  107. package/build/lib/utils.d.ts +0 -10
  108. package/build/lib/utils.d.ts.map +0 -1
  109. package/build/lib/utils.js +0 -26
  110. package/build/lib/utils.js.map +0 -1
  111. package/lib/commands/general.js +0 -289
  112. package/lib/commands/index.js +0 -11
  113. package/lib/commands/mixins.ts +0 -169
  114. package/lib/utils.js +0 -19
@@ -1,289 +0,0 @@
1
- // @ts-check
2
-
3
- import _ from 'lodash';
4
- import B from 'bluebird';
5
- import {errors, PROTOCOLS} from 'appium/driver';
6
- import {APK_EXTENSION} from '../extensions';
7
- import {mixin} from './mixins';
8
- import {AndroidUiautomator2Driver} from '../driver';
9
-
10
- const MOBILE_SCRIPT_NAME_PREFIX = 'mobile:';
11
-
12
- /**
13
- * Massages the arguments going into an execute method.
14
- * @remarks A similar method is implemented in `appium-xcuitest-driver`, but it
15
- * appears the methods in here handle unwrapping of `Element` objects, so we do
16
- * not do that here.
17
- * @param {readonly any[] | readonly [StringRecord] | Readonly<StringRecord>} [args]
18
- * @internal
19
- * @returns {StringRecord<unknown>}
20
- */
21
- function preprocessExecuteMethodArgs(args) {
22
- if (_.isArray(args)) {
23
- args = _.first(args);
24
- }
25
- const executeMethodArgs = /** @type {StringRecord<unknown>} */ (args ?? {});
26
- /**
27
- * Renames the deprecated `element` key to `elementId`. Historically,
28
- * all of the pre-Execute-Method-Map execute methods accepted an `element` _or_ and `elementId` param.
29
- * This assigns the `element` value to `elementId` if `elementId` is not already present.
30
- */
31
- if (!('elementId' in executeMethodArgs) && 'element' in executeMethodArgs) {
32
- executeMethodArgs.elementId = executeMethodArgs.element;
33
- delete executeMethodArgs.element;
34
- }
35
-
36
- return executeMethodArgs;
37
- }
38
-
39
- /**
40
- * Type guard to check if a script is an execute method.
41
- * @param {any} script
42
- * @internal
43
- * @returns {string?}
44
- */
45
- function toExecuteMethodName(script) {
46
- return _.startsWith(script, MOBILE_SCRIPT_NAME_PREFIX)
47
- ? script.replace(new RegExp(`${MOBILE_SCRIPT_NAME_PREFIX}\\s*`), `${MOBILE_SCRIPT_NAME_PREFIX} `)
48
- : null;
49
- }
50
-
51
- /**
52
- * @type {import('./mixins').UIA2GeneralMixin}
53
- * @satisfies {import('@appium/types').ExternalDriver}
54
- */
55
- const GeneralMixin = {
56
- async getPageSource() {
57
- return String(
58
- await this.uiautomator2.jwproxy.command(
59
- '/source',
60
- 'GET',
61
- {}
62
- )
63
- );
64
- },
65
-
66
- async getClipboard() {
67
- return String(
68
- (await this.adb.getApiLevel()) < 29
69
- ? await this.uiautomator2.jwproxy.command(
70
- '/appium/device/get_clipboard',
71
- 'POST',
72
- {}
73
- )
74
- : await this.settingsApp.getClipboard()
75
- );
76
- },
77
-
78
- async doSendKeys(params) {
79
- await this.uiautomator2.jwproxy.command(
80
- '/keys',
81
- 'POST',
82
- params
83
- );
84
- },
85
-
86
- async keyevent(keycode, metastate) {
87
- this.log.debug(`Ignoring metastate ${metastate}`);
88
- await this.adb.keyevent(keycode);
89
- },
90
-
91
- async back() {
92
- await this.adb.keyevent(4);
93
- },
94
-
95
- async getDisplayDensity() {
96
- return /** @type {number} */ (
97
- await this.uiautomator2.jwproxy.command(
98
- '/appium/device/display_density',
99
- 'GET',
100
- {}
101
- )
102
- );
103
- },
104
-
105
- async getWindowSize() {
106
- return /** @type {import('@appium/types').Size} */ (
107
- await this.uiautomator2.jwproxy.command(
108
- '/window/current/size',
109
- 'GET',
110
- {}
111
- )
112
- );
113
- },
114
-
115
- // For W3C
116
- async getWindowRect() {
117
- const {width, height} = await this.getWindowSize();
118
- return {
119
- width,
120
- height,
121
- x: 0,
122
- y: 0,
123
- };
124
- },
125
-
126
- /**
127
- * @override
128
- * @privateRemarks Because the "mobile" commands (execute methods) in this
129
- * driver universally accept an options object, this method will _not_ call
130
- * into `BaseDriver.executeMethod`.
131
- */
132
- async execute(script, args) {
133
- const mobileScriptName = toExecuteMethodName(script);
134
- const isWebContext = this.isWebContext();
135
- if (mobileScriptName && isWebContext || !isWebContext) {
136
- if (mobileScriptName) {
137
- const executeMethodArgs = preprocessExecuteMethodArgs(args);
138
- this.log.info(`Executing method '${mobileScriptName}'`);
139
- return await this.executeMobile(mobileScriptName, executeMethodArgs);
140
- }
141
- // Just pass the script name through and let it fail with a proper error message
142
- return await this.executeMobile(`${script}`, {});
143
- }
144
- const endpoint =
145
- /** @type {import('appium-chromedriver').Chromedriver} */ (this.chromedriver).jwproxy
146
- .downstreamProtocol === PROTOCOLS.MJSONWP
147
- ? '/execute'
148
- : '/execute/sync';
149
- return await /** @type {import('appium-chromedriver').Chromedriver} */ (
150
- this.chromedriver
151
- ).jwproxy.command(endpoint, 'POST', {
152
- script,
153
- args,
154
- });
155
- },
156
-
157
- /**
158
- * @param script Must be of the form `mobile: <something>`, which differs from its parent class implementation.
159
- * @override
160
- */
161
- async executeMobile(script, opts = {}) {
162
- if (!(script in AndroidUiautomator2Driver.executeMethodMap)) {
163
- const commandNames = _.map(
164
- _.keys(AndroidUiautomator2Driver.executeMethodMap),
165
- (value) => value.slice(8)
166
- );
167
- throw new errors.UnknownCommandError(
168
- `Unknown mobile command "${script}". ` +
169
- `Only ${commandNames.join(', ')} commands are supported.`
170
- );
171
- }
172
- const methodName =
173
- AndroidUiautomator2Driver.executeMethodMap[
174
- /** @type {keyof import('../execute-method-map').Uiautomator2ExecuteMethodMap} */ (script)
175
- ].command;
176
-
177
- return await /** @type {(opts?: any) => Promise<unknown>} */ (this[methodName])(opts);
178
- },
179
-
180
- async mobileViewportScreenshot() {
181
- return await this.getViewportScreenshot();
182
- },
183
-
184
- /**
185
- * Returns the viewport coordinates.
186
- * @returns The viewport coordinates.
187
- */
188
- async mobileViewPortRect() {
189
- return await this.getViewPortRect();
190
- },
191
-
192
- async setUrl(url) {
193
- await this.adb.startUri(url, /** @type {string} */ (this.opts.appPackage));
194
- },
195
-
196
- /**
197
- * Start URL that take users directly to specific content in the app
198
- */
199
- async mobileDeepLink(opts) {
200
- const {url, package: pkg, waitForLaunch} = opts;
201
- return await this.adb.startUri(url, pkg, {waitForLaunch});
202
- },
203
-
204
- async openNotifications() {
205
- await this.uiautomator2.jwproxy.command(
206
- '/appium/device/open_notifications',
207
- 'POST',
208
- {}
209
- );
210
- },
211
-
212
- // Stop proxying to any Chromedriver and redirect to uiautomator2
213
- suspendChromedriverProxy() {
214
- this.chromedriver = undefined;
215
- this.proxyReqRes = this.uiautomator2.proxyReqRes.bind(
216
- this.uiautomator2
217
- );
218
- this.proxyCommand = /** @type {typeof this.proxyCommand} */ (
219
- this.uiautomator2.proxyCommand.bind(this.uiautomator2)
220
- );
221
- this.jwpProxyActive = true;
222
- },
223
-
224
- /**
225
- * The list of available info entries can be found at
226
- * https://github.com/appium/appium-uiautomator2-server/blob/master/app/src/main/java/io/appium/uiautomator2/handler/GetDeviceInfo.java
227
- */
228
- async mobileGetDeviceInfo() {
229
- return /** @type {StringRecord} */ (
230
- await this.uiautomator2.jwproxy.command(
231
- '/appium/device/info',
232
- 'GET'
233
- )
234
- );
235
- },
236
-
237
- /**
238
- * Types the given Unicode string.
239
- * It is expected that the focus is already put
240
- * to the destination input field before this method is called.
241
- *
242
- * @returns `true` if the input text has been successfully sent to adb
243
- * @throws {Error} if `text` property has not been provided
244
- */
245
- async mobileType(opts) {
246
- const {text} = opts;
247
- if (_.isUndefined(text)) {
248
- this.log.errorAndThrow(`The 'text' argument is mandatory`);
249
- throw new Error(); // unreachable
250
- }
251
- return await this.settingsApp.typeUnicode(String(text));
252
- },
253
-
254
- /**
255
- * Install multiple APKs with `install-multiple` option.
256
- *
257
- * @throws {Error} if an error occured while installing the given APKs.
258
- */
259
- async mobileInstallMultipleApks(opts) {
260
- if (!_.isArray(opts.apks) || _.isEmpty(opts.apks)) {
261
- throw new errors.InvalidArgumentError('No apks are given to install');
262
- }
263
- const apks = await B.all(
264
- opts.apks.map((app) => this.helpers.configureApp(app, [APK_EXTENSION]))
265
- );
266
- await this.adb.installMultipleApks(apks, opts.options);
267
- },
268
-
269
- /**
270
- * Puts the app to background and waits the given number of seconds Then restores the app
271
- * if necessary. The call is blocking.
272
- */
273
- async mobileBackgroundApp(opts = {}) {
274
- const {seconds = -1} = opts;
275
- await this.background(seconds);
276
- },
277
- };
278
-
279
- mixin(GeneralMixin);
280
-
281
- /**
282
- * @typedef {import('../uiautomator2').UiAutomator2Server} UiAutomator2Server
283
- * @typedef {import('appium-adb').ADB} ADB
284
- */
285
-
286
- /**
287
- * @template [T=any]
288
- * @typedef {import('@appium/types').StringRecord<T>} StringRecord
289
- */
@@ -1,11 +0,0 @@
1
- import './alert';
2
- import './find';
3
- import './general';
4
- import './touch';
5
- import './element';
6
- import './actions';
7
- import './viewport';
8
- import './screenshot';
9
- import './battery';
10
- import './gestures';
11
- import './app-strings';
@@ -1,169 +0,0 @@
1
- /**
2
- * @module
3
- * @privateRemarks These mixins are kind of a mishmash of stuff from `appium-android-driver`,
4
- * @privateRemarks unique things, and stuff from `ExternalDriver`. Ideally, we should be pulling the method
5
- * @privateRemarks definitions right out of `ExternalDriver` whenever possible. Also note that the mixins
6
- * @privateRemarks contain _more stuff than just commands or execute methods_.
7
- */
8
-
9
- import type {Element, ExternalDriver, StringRecord} from '@appium/types';
10
- import type {
11
- ActionsMixin,
12
- AlertMixin,
13
- ElementMixin,
14
- ExecuteMixin,
15
- FindMixin,
16
- GeneralMixin,
17
- NetworkMixin,
18
- TouchMixin,
19
- } from 'appium-android-driver';
20
- import type {EmptyObject} from 'type-fest';
21
- import {AndroidUiautomator2Driver} from '../driver';
22
- import type * as types from './types';
23
-
24
- type UIA2Mixin<T = EmptyObject> = ThisType<import('../driver').AndroidUiautomator2Driver> & T;
25
-
26
- export type UIA2ActionsMixin = UIA2Mixin<
27
- Pick<
28
- ActionsMixin,
29
- 'pressKeyCode' | 'longPressKeyCode' | 'doSwipe' | 'doDrag' | 'getOrientation' | 'setOrientation'
30
- >
31
- > & {
32
- mobilePressKey(opts: types.PressKeyOptions): Promise<void>;
33
- mobileScheduleAction(opts?: StringRecord): Promise<unknown>;
34
- mobileGetActionHistory(opts?: types.ActionArgs): Promise<types.ActionResult>;
35
- mobileUnscheduleAction(opts?: types.ActionArgs): Promise<unknown>;
36
- };
37
-
38
- export type UIA2AlertMixin = UIA2Mixin<
39
- Pick<AlertMixin, 'getAlertText' | 'postAcceptAlert' | 'postDismissAlert'>
40
- > & {
41
- mobileAcceptAlert(opts?: types.AcceptAlertOptions): Promise<void>;
42
- mobileDismissAlert(opts?: types.DismissAlertOptions): Promise<void>;
43
- };
44
-
45
- export type UIA2AppStringsMixin = UIA2Mixin<Pick<GeneralMixin, 'getStrings'>> & {
46
- mobileGetAppStrings(opts?: types.GetAppStringsOptions): Promise<StringRecord>;
47
- };
48
-
49
- export type UIA2BatteryMixin = UIA2Mixin & {
50
- mobileGetBatteryInfo(): Promise<types.BatteryInfo>;
51
- };
52
-
53
- export type UIA2ElementMixin = UIA2Mixin<
54
- Pick<
55
- ElementMixin,
56
- | 'getAttribute'
57
- | 'elementDisplayed'
58
- | 'elementEnabled'
59
- | 'elementSelected'
60
- | 'getName'
61
- | 'getLocation'
62
- | 'getSize'
63
- | 'touchLongClick'
64
- | 'touchDown'
65
- | 'touchUp'
66
- | 'touchMove'
67
- | 'doSetElementValue'
68
- | 'setValueImmediate'
69
- | 'getText'
70
- | 'click'
71
- | 'tap'
72
- | 'clear'
73
- | 'getElementRect'
74
- >
75
- > & {
76
- active(): Promise<Element>;
77
- mobileReplaceElementValue(opts: types.ReplaceValueOptions): Promise<void>;
78
- getElementScreenshot(elementId: string): Promise<string>;
79
- };
80
-
81
- export type UIA2FindMixin = UIA2Mixin<Pick<FindMixin, 'doFindElementOrEls'>>;
82
-
83
- export type UIA2GeneralMixin = UIA2Mixin<
84
- Pick<
85
- GeneralMixin & NetworkMixin & ActionsMixin & ExecuteMixin,
86
- | 'getPageSource'
87
- | 'doSendKeys'
88
- | 'back'
89
- | 'getDisplayDensity'
90
- | 'getWindowSize'
91
- | 'getWindowRect'
92
- | 'setUrl'
93
- | 'keyevent'
94
- | 'execute'
95
- | 'executeMobile'
96
- >
97
- > & {
98
- getClipboard(): Promise<string>;
99
- mobileViewportScreenshot(): Promise<string>;
100
- mobileViewPortRect(): Promise<types.RelativeRect>;
101
- mobileDeepLink(opts: types.DeepLinkOpts): Promise<void>;
102
- openNotifications(): Promise<void>;
103
- suspendChromedriverProxy(): void;
104
- mobileGetDeviceInfo(): Promise<StringRecord>;
105
- mobileType(opts: types.TypingOptions): Promise<boolean>;
106
- mobileInstallMultipleApks(opts: types.InstallMultipleApksOptions): Promise<void>;
107
- mobileBackgroundApp(opts?: types.BackgroundAppOptions): Promise<void>;
108
- };
109
-
110
- export type UIA2ViewportMixin = UIA2Mixin & {
111
- getStatusBarHeight(): Promise<number>;
112
- getDevicePixelRatio(): Promise<string>;
113
- getViewportScreenshot(): Promise<string>;
114
- getViewPortRect(): Promise<types.RelativeRect>;
115
- };
116
-
117
- export type UIA2GesturesMixin = UIA2Mixin & {
118
- mobileClickGesture(opts?: types.ClickOptions): Promise<void>;
119
- mobileDoubleClickGesture(opts?: types.ClickOptions): Promise<void>;
120
- mobileDragGesture(opts: types.DragOptions): Promise<void>;
121
- mobileFlingGesture(opts: types.FlingOptions): Promise<boolean>;
122
- mobilePinchCloseGesture(opts: types.PinchOptions): Promise<void>;
123
- mobilePinchOpenGesture(opts: types.PinchOptions): Promise<void>;
124
- mobileSwipeGesture(opts: types.SwipeOptions): Promise<void>;
125
- mobileScrollGesture(opts: types.ScrollGestureOptions): Promise<boolean>;
126
- mobileScrollBackTo(opts: types.ScrollElementToElementOpts): Promise<void>;
127
- mobileScroll(opts: types.ScrollOptions): Promise<void>;
128
- mobileLongClickGesture(opts: types.LongClickOptions): Promise<void>;
129
- };
130
-
131
- export type UIA2ScreenshotMixin = UIA2Mixin<Pick<ActionsMixin, 'getScreenshot'>> & {
132
- mobileScreenshots(opts: types.ScreenshotsOpts): Promise<StringRecord<types.Screenshot>>;
133
- };
134
-
135
- export type UIA2TouchMixin = UIA2Mixin<
136
- // Required needed because ExternalDriver's methods are all optional
137
- Required<
138
- Pick<ExternalDriver & TouchMixin, 'performActions' | 'releaseActions' | 'doPerformMultiAction'>
139
- >
140
- >;
141
-
142
- declare module '../driver' {
143
- interface AndroidUiautomator2Driver
144
- extends UIA2ActionsMixin,
145
- UIA2AlertMixin,
146
- UIA2AppStringsMixin,
147
- UIA2BatteryMixin,
148
- UIA2ElementMixin,
149
- UIA2FindMixin,
150
- UIA2GeneralMixin,
151
- UIA2GesturesMixin,
152
- UIA2ScreenshotMixin,
153
- UIA2TouchMixin,
154
- UIA2ViewportMixin {}
155
- }
156
-
157
- /**
158
- * This function assigns a mixin `T` to the `AndroidUiautomator2Driver` class' prototype.
159
- *
160
- * While each mixin has its own interface which is (in isolation) unrelated to
161
- * `AndroidUiautomator2Driver`, the constraint on this generic type `T` is that it must be a
162
- * partial of `AndroidUiautomator2Driver`'s interface. This enforces that it does not
163
- * conflict with the existing interface of `AndroidUiautomator2Driver`. In that way, you
164
- * can think of it as a type guard.
165
- * @param mixin Mixin implementation
166
- */
167
- export function mixin<T extends Partial<AndroidUiautomator2Driver>>(mixin: T): void {
168
- Object.assign(AndroidUiautomator2Driver.prototype, mixin);
169
- }
package/lib/utils.js DELETED
@@ -1,19 +0,0 @@
1
- import _ from 'lodash';
2
- import { errors } from 'appium/driver';
3
-
4
- /**
5
- * Assert the presence of particular keys in the given object
6
- *
7
- * @template {Record<string, any>} T
8
- * @param {string|string[]} argNames one or more key names
9
- * @param {T} opts the object to check
10
- * @returns {T} the same given object
11
- */
12
- export function requireArgs (argNames, opts) {
13
- for (const argName of (_.isArray(argNames) ? argNames : [argNames])) {
14
- if (!_.has(opts, argName)) {
15
- throw new errors.InvalidArgumentError(`'${argName}' argument must be provided`);
16
- }
17
- }
18
- return opts;
19
- }