appium-android-driver 5.14.7 → 6.0.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 (210) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/build/lib/commands/actions.d.ts +6 -224
  3. package/build/lib/commands/actions.d.ts.map +1 -1
  4. package/build/lib/commands/actions.js +306 -405
  5. package/build/lib/commands/actions.js.map +1 -1
  6. package/build/lib/commands/alert.d.ts +7 -9
  7. package/build/lib/commands/alert.d.ts.map +1 -1
  8. package/build/lib/commands/alert.js +24 -18
  9. package/build/lib/commands/alert.js.map +1 -1
  10. package/build/lib/commands/app-management.d.ts +7 -313
  11. package/build/lib/commands/app-management.d.ts.map +1 -1
  12. package/build/lib/commands/app-management.js +135 -293
  13. package/build/lib/commands/app-management.js.map +1 -1
  14. package/build/lib/commands/context.d.ts +8 -92
  15. package/build/lib/commands/context.d.ts.map +1 -1
  16. package/build/lib/commands/context.js +381 -439
  17. package/build/lib/commands/context.js.map +1 -1
  18. package/build/lib/commands/element.d.ts +8 -35
  19. package/build/lib/commands/element.d.ts.map +1 -1
  20. package/build/lib/commands/element.js +153 -136
  21. package/build/lib/commands/element.js.map +1 -1
  22. package/build/lib/commands/emu-console.d.ts +6 -48
  23. package/build/lib/commands/emu-console.d.ts.map +1 -1
  24. package/build/lib/commands/emu-console.js +19 -34
  25. package/build/lib/commands/emu-console.js.map +1 -1
  26. package/build/lib/commands/execute.d.ts +6 -5
  27. package/build/lib/commands/execute.d.ts.map +1 -1
  28. package/build/lib/commands/execute.js +77 -66
  29. package/build/lib/commands/execute.js.map +1 -1
  30. package/build/lib/commands/file-actions.d.ts +7 -128
  31. package/build/lib/commands/file-actions.d.ts.map +1 -1
  32. package/build/lib/commands/file-actions.js +183 -219
  33. package/build/lib/commands/file-actions.js.map +1 -1
  34. package/build/lib/commands/find.d.ts +8 -12
  35. package/build/lib/commands/find.d.ts.map +1 -1
  36. package/build/lib/commands/find.js +19 -23
  37. package/build/lib/commands/find.js.map +1 -1
  38. package/build/lib/commands/general.d.ts +9 -132
  39. package/build/lib/commands/general.d.ts.map +1 -1
  40. package/build/lib/commands/general.js +281 -312
  41. package/build/lib/commands/general.js.map +1 -1
  42. package/build/lib/commands/ime.d.ts +7 -10
  43. package/build/lib/commands/ime.d.ts.map +1 -1
  44. package/build/lib/commands/ime.js +47 -35
  45. package/build/lib/commands/ime.js.map +1 -1
  46. package/build/lib/commands/index.d.ts +27 -2
  47. package/build/lib/commands/index.d.ts.map +1 -1
  48. package/build/lib/commands/index.js +41 -19
  49. package/build/lib/commands/index.js.map +1 -1
  50. package/build/lib/commands/intent.d.ts +7 -417
  51. package/build/lib/commands/intent.d.ts.map +1 -1
  52. package/build/lib/commands/intent.js +104 -216
  53. package/build/lib/commands/intent.js.map +1 -1
  54. package/build/lib/commands/keyboard.d.ts +6 -5
  55. package/build/lib/commands/keyboard.d.ts.map +1 -1
  56. package/build/lib/commands/keyboard.js +16 -8
  57. package/build/lib/commands/keyboard.js.map +1 -1
  58. package/build/lib/commands/log.d.ts +7 -44
  59. package/build/lib/commands/log.d.ts.map +1 -1
  60. package/build/lib/commands/log.js +146 -108
  61. package/build/lib/commands/log.js.map +1 -1
  62. package/build/lib/commands/media-projection.d.ts +7 -143
  63. package/build/lib/commands/media-projection.d.ts.map +1 -1
  64. package/build/lib/commands/media-projection.js +113 -140
  65. package/build/lib/commands/media-projection.js.map +1 -1
  66. package/build/lib/commands/mixins.d.ts +740 -0
  67. package/build/lib/commands/mixins.d.ts.map +1 -0
  68. package/build/lib/commands/mixins.js +19 -0
  69. package/build/lib/commands/mixins.js.map +1 -0
  70. package/build/lib/commands/network.d.ts +7 -138
  71. package/build/lib/commands/network.d.ts.map +1 -1
  72. package/build/lib/commands/network.js +212 -254
  73. package/build/lib/commands/network.js.map +1 -1
  74. package/build/lib/commands/performance.d.ts +24 -70
  75. package/build/lib/commands/performance.d.ts.map +1 -1
  76. package/build/lib/commands/performance.js +144 -100
  77. package/build/lib/commands/performance.js.map +1 -1
  78. package/build/lib/commands/permissions.d.ts +8 -92
  79. package/build/lib/commands/permissions.d.ts.map +1 -1
  80. package/build/lib/commands/permissions.js +75 -87
  81. package/build/lib/commands/permissions.js.map +1 -1
  82. package/build/lib/commands/recordscreen.d.ts +7 -193
  83. package/build/lib/commands/recordscreen.d.ts.map +1 -1
  84. package/build/lib/commands/recordscreen.js +151 -182
  85. package/build/lib/commands/recordscreen.js.map +1 -1
  86. package/build/lib/commands/shell.d.ts +7 -7
  87. package/build/lib/commands/shell.d.ts.map +1 -1
  88. package/build/lib/commands/shell.js +40 -33
  89. package/build/lib/commands/shell.js.map +1 -1
  90. package/build/lib/commands/streamscreen.d.ts +9 -103
  91. package/build/lib/commands/streamscreen.d.ts.map +1 -1
  92. package/build/lib/commands/streamscreen.js +261 -218
  93. package/build/lib/commands/streamscreen.js.map +1 -1
  94. package/build/lib/commands/system-bars.d.ts +22 -90
  95. package/build/lib/commands/system-bars.d.ts.map +1 -1
  96. package/build/lib/commands/system-bars.js +76 -74
  97. package/build/lib/commands/system-bars.js.map +1 -1
  98. package/build/lib/commands/touch.d.ts +10 -29
  99. package/build/lib/commands/touch.d.ts.map +1 -1
  100. package/build/lib/commands/touch.js +301 -285
  101. package/build/lib/commands/touch.js.map +1 -1
  102. package/build/lib/commands/types.d.ts +978 -0
  103. package/build/lib/commands/types.d.ts.map +1 -0
  104. package/build/lib/commands/types.js +3 -0
  105. package/build/lib/commands/types.js.map +1 -0
  106. package/build/lib/constraints.d.ts +291 -0
  107. package/build/lib/constraints.d.ts.map +1 -0
  108. package/build/lib/{desired-caps.js → constraints.js} +103 -102
  109. package/build/lib/constraints.js.map +1 -0
  110. package/build/lib/driver.d.ts +68 -37
  111. package/build/lib/driver.d.ts.map +1 -1
  112. package/build/lib/driver.js +123 -80
  113. package/build/lib/driver.js.map +1 -1
  114. package/build/lib/helpers/android.d.ts +164 -0
  115. package/build/lib/helpers/android.d.ts.map +1 -0
  116. package/build/lib/helpers/android.js +819 -0
  117. package/build/lib/helpers/android.js.map +1 -0
  118. package/build/lib/helpers/index.d.ts +7 -0
  119. package/build/lib/helpers/index.d.ts.map +1 -0
  120. package/build/lib/helpers/index.js +29 -0
  121. package/build/lib/helpers/index.js.map +1 -0
  122. package/build/lib/helpers/types.d.ts +121 -0
  123. package/build/lib/helpers/types.d.ts.map +1 -0
  124. package/build/lib/helpers/types.js +3 -0
  125. package/build/lib/helpers/types.js.map +1 -0
  126. package/build/lib/helpers/unlock.d.ts +32 -0
  127. package/build/lib/helpers/unlock.d.ts.map +1 -0
  128. package/build/lib/helpers/unlock.js +273 -0
  129. package/build/lib/helpers/unlock.js.map +1 -0
  130. package/build/lib/helpers/webview.d.ts +74 -0
  131. package/build/lib/helpers/webview.d.ts.map +1 -0
  132. package/build/lib/helpers/webview.js +421 -0
  133. package/build/lib/helpers/webview.js.map +1 -0
  134. package/build/lib/index.d.ts +9 -0
  135. package/build/lib/index.d.ts.map +1 -0
  136. package/build/lib/index.js +37 -0
  137. package/build/lib/index.js.map +1 -0
  138. package/build/lib/method-map.d.ts +0 -8
  139. package/build/lib/method-map.d.ts.map +1 -1
  140. package/build/lib/method-map.js +63 -74
  141. package/build/lib/method-map.js.map +1 -1
  142. package/build/lib/stubs.d.ts +0 -1
  143. package/build/lib/stubs.d.ts.map +1 -1
  144. package/build/lib/stubs.js +1 -0
  145. package/build/lib/stubs.js.map +1 -1
  146. package/build/lib/utils.d.ts +1 -1
  147. package/build/lib/utils.d.ts.map +1 -1
  148. package/lib/commands/actions.js +351 -464
  149. package/lib/commands/alert.js +27 -17
  150. package/lib/commands/app-management.js +156 -314
  151. package/lib/commands/context.js +457 -441
  152. package/lib/commands/element.js +201 -157
  153. package/lib/commands/emu-console.js +25 -45
  154. package/lib/commands/execute.js +106 -90
  155. package/lib/commands/file-actions.js +222 -240
  156. package/lib/commands/find.ts +103 -0
  157. package/lib/commands/general.js +327 -339
  158. package/lib/commands/ime.js +50 -34
  159. package/lib/commands/{index.js → index.ts} +20 -24
  160. package/lib/commands/intent.js +108 -249
  161. package/lib/commands/keyboard.js +20 -8
  162. package/lib/commands/log.js +172 -116
  163. package/lib/commands/media-projection.js +134 -161
  164. package/lib/commands/mixins.ts +966 -0
  165. package/lib/commands/network.js +252 -281
  166. package/lib/commands/performance.js +203 -132
  167. package/lib/commands/permissions.js +108 -109
  168. package/lib/commands/recordscreen.js +212 -209
  169. package/lib/commands/shell.js +51 -40
  170. package/lib/commands/streamscreen.js +355 -289
  171. package/lib/commands/system-bars.js +92 -83
  172. package/lib/commands/touch.js +357 -294
  173. package/lib/commands/types.ts +1097 -0
  174. package/lib/{desired-caps.js → constraints.ts} +106 -103
  175. package/lib/{driver.js → driver.ts} +278 -132
  176. package/lib/helpers/android.ts +1143 -0
  177. package/lib/helpers/index.ts +6 -0
  178. package/lib/helpers/types.ts +134 -0
  179. package/lib/helpers/unlock.ts +329 -0
  180. package/lib/helpers/webview.ts +582 -0
  181. package/lib/index.ts +18 -0
  182. package/lib/method-map.js +87 -98
  183. package/lib/stubs.ts +0 -1
  184. package/package.json +26 -19
  185. package/build/index.js +0 -51
  186. package/build/lib/android-helpers.d.ts +0 -136
  187. package/build/lib/android-helpers.d.ts.map +0 -1
  188. package/build/lib/android-helpers.js +0 -855
  189. package/build/lib/android-helpers.js.map +0 -1
  190. package/build/lib/commands/coverage.d.ts +0 -5
  191. package/build/lib/commands/coverage.d.ts.map +0 -1
  192. package/build/lib/commands/coverage.js +0 -19
  193. package/build/lib/commands/coverage.js.map +0 -1
  194. package/build/lib/desired-caps.d.ts +0 -353
  195. package/build/lib/desired-caps.d.ts.map +0 -1
  196. package/build/lib/desired-caps.js.map +0 -1
  197. package/build/lib/unlock-helpers.d.ts +0 -38
  198. package/build/lib/unlock-helpers.d.ts.map +0 -1
  199. package/build/lib/unlock-helpers.js +0 -266
  200. package/build/lib/unlock-helpers.js.map +0 -1
  201. package/build/lib/webview-helpers.d.ts +0 -224
  202. package/build/lib/webview-helpers.d.ts.map +0 -1
  203. package/build/lib/webview-helpers.js +0 -528
  204. package/build/lib/webview-helpers.js.map +0 -1
  205. package/index.js +0 -24
  206. package/lib/android-helpers.js +0 -983
  207. package/lib/commands/coverage.js +0 -18
  208. package/lib/commands/find.js +0 -82
  209. package/lib/unlock-helpers.js +0 -278
  210. package/lib/webview-helpers.js +0 -602
@@ -1,144 +1,200 @@
1
- import log from '../logger';
2
- import os from 'os';
1
+ // @ts-check
2
+
3
+ import {DEFAULT_WS_PATHNAME_PREFIX, BaseDriver} from 'appium/driver';
3
4
  import _ from 'lodash';
5
+ import os from 'node:os';
4
6
  import WebSocket from 'ws';
5
- import { DEFAULT_WS_PATHNAME_PREFIX, BaseDriver } from 'appium/driver';
7
+ import log from '../logger';
8
+ import {mixin} from './mixins';
6
9
 
7
10
  const GET_SERVER_LOGS_FEATURE = 'get_server_logs';
8
11
 
9
- let commands = {}, helpers = {}, extensions = {};
10
-
11
- const WEBSOCKET_ENDPOINT = (sessionId) => `${DEFAULT_WS_PATHNAME_PREFIX}/session/${sessionId}/appium/device/logcat`;
12
+ /**
13
+ * @param {string} sessionId
14
+ * @returns {string}
15
+ */
16
+ const WEBSOCKET_ENDPOINT = (sessionId) =>
17
+ `${DEFAULT_WS_PATHNAME_PREFIX}/session/${sessionId}/appium/device/logcat`;
12
18
 
13
- // https://github.com/SeleniumHQ/selenium/blob/0d425676b3c9df261dd641917f867d4d5ce7774d/java/client/src/org/openqa/selenium/logging/LogEntry.java
14
- function toLogRecord (timestamp, level, message) {
19
+ /**
20
+ *
21
+ * @see {@link https://github.com/SeleniumHQ/selenium/blob/0d425676b3c9df261dd641917f867d4d5ce7774d/java/client/src/org/openqa/selenium/logging/LogEntry.java}
22
+ * @param {number} timestamp
23
+ * @param {string} level
24
+ * @param {string} message
25
+ */
26
+ function toLogRecord(timestamp, level, message) {
15
27
  return {
16
28
  timestamp,
17
29
  level,
18
30
  message,
19
31
  };
20
32
  }
21
-
22
- extensions.supportedLogTypes = {
23
- logcat: {
24
- description: 'Logs for Android applications on real device and emulators via ADB',
25
- getter: async (self) => await self.adb.getLogcatLogs(),
26
- },
27
- bugreport: {
28
- description: `'adb bugreport' output for advanced issues diagnostic`,
29
- getter: async (self) => {
30
- const output = await self.adb.bugreport();
31
- const timestamp = Date.now();
32
- return output.split(os.EOL)
33
- .map((x) => toLogRecord(timestamp, 'ALL', x));
33
+ /**
34
+ * @type {import('./mixins').LogMixin & ThisType<import('../driver').AndroidDriver>}
35
+ * @satisfies {import('@appium/types').ExternalDriver}
36
+ */
37
+ const LogMixin = {
38
+ supportedLogTypes: {
39
+ logcat: {
40
+ description: 'Logs for Android applications on real device and emulators via ADB',
41
+ /**
42
+ *
43
+ * @param {import('../driver').AndroidDriver} self
44
+ * @returns
45
+ */
46
+ getter: (self) => /** @type {ADB} */ (self.adb).getLogcatLogs(),
34
47
  },
35
- },
36
- server: {
37
- description: 'Appium server logs',
38
- getter: (self) => {
39
- self.ensureFeatureEnabled(GET_SERVER_LOGS_FEATURE);
40
- const timestamp = Date.now();
41
- return log.unwrap().record
42
- .map((x) => toLogRecord(timestamp,
43
- 'ALL',
44
- _.isEmpty(x.prefix) ? x.message : `[${x.prefix}] ${x.message}`)
45
- );
48
+ bugreport: {
49
+ description: `'adb bugreport' output for advanced issues diagnostic`,
50
+ /**
51
+ *
52
+ * @param {import('../driver').AndroidDriver} self
53
+ * @returns
54
+ */
55
+ getter: async (self) => {
56
+ const output = await /** @type {ADB} */ (self.adb).bugreport();
57
+ const timestamp = Date.now();
58
+ return output.split(os.EOL).map((x) => toLogRecord(timestamp, 'ALL', x));
59
+ },
60
+ },
61
+ server: {
62
+ description: 'Appium server logs',
63
+ /**
64
+ *
65
+ * @param {import('../driver').AndroidDriver} self
66
+ * @returns
67
+ */
68
+ getter: (self) => {
69
+ self.ensureFeatureEnabled(GET_SERVER_LOGS_FEATURE);
70
+ const timestamp = Date.now();
71
+ return log
72
+ .unwrap()
73
+ .record.map((x) =>
74
+ toLogRecord(
75
+ timestamp,
76
+ 'ALL',
77
+ _.isEmpty(x.prefix) ? x.message : `[${x.prefix}] ${x.message}`
78
+ )
79
+ );
80
+ },
46
81
  },
47
82
  },
48
- };
49
83
 
50
- /**
51
- * Starts Android logcat broadcast websocket on the same host and port
52
- * where Appium server is running at `/ws/session/:sessionId:/appium/logcat` endpoint. The method
53
- * will return immediately if the web socket is already listening.
54
- *
55
- * Each connected websocket listener will receive logcat log lines
56
- * as soon as they are visible to Appium.
57
- */
58
- commands.mobileStartLogsBroadcast = async function mobileStartLogsBroadcast () {
59
- const pathname = WEBSOCKET_ENDPOINT(this.sessionId);
60
- if (!_.isEmpty(await this.server.getWebSocketHandlers(pathname))) {
61
- log.debug(`The logcat broadcasting web socket server is already listening at ${pathname}`);
62
- return;
63
- }
64
-
65
- log.info(`Starting logcat broadcasting on web socket server ` +
66
- `${JSON.stringify(this.server.address())} to ${pathname}`);
67
- // https://github.com/websockets/ws/blob/master/doc/ws.md
68
- const wss = new WebSocket.Server({
69
- noServer: true,
70
- });
71
- wss.on('connection', (ws, req) => {
72
- if (req) {
73
- const remoteIp = _.isEmpty(req.headers['x-forwarded-for'])
74
- ? req.connection?.remoteAddress
75
- : req.headers['x-forwarded-for'];
76
- log.debug(`Established a new logcat listener web socket connection from ${remoteIp}`);
77
- } else {
78
- log.debug('Established a new logcat listener web socket connection');
79
- }
80
-
81
- if (_.isEmpty(this._logcatWebsocketListener)) {
82
- this._logcatWebsocketListener = (logRecord) => {
83
- if (ws?.readyState === WebSocket.OPEN) {
84
- ws.send(logRecord.message);
85
- }
86
- };
84
+ /**
85
+ * Starts Android logcat broadcast websocket on the same host and port
86
+ * where Appium server is running at `/ws/session/:sessionId:/appium/logcat` endpoint. The method
87
+ * will return immediately if the web socket is already listening.
88
+ *
89
+ * Each connected websocket listener will receive logcat log lines
90
+ * as soon as they are visible to Appium.
91
+ */
92
+ async mobileStartLogsBroadcast() {
93
+ const server = /** @type {import('@appium/types').AppiumServer} */ (this.server);
94
+ const adb = /** @type {ADB} */ (this.adb);
95
+ const pathname = WEBSOCKET_ENDPOINT(/** @type {string} */ (this.sessionId));
96
+ if (!_.isEmpty(await server.getWebSocketHandlers(pathname))) {
97
+ log.debug(`The logcat broadcasting web socket server is already listening at ${pathname}`);
98
+ return;
87
99
  }
88
- this.adb.setLogcatListener(this._logcatWebsocketListener);
89
100
 
90
- ws.on('close', (code, reason) => {
91
- if (!_.isEmpty(this._logcatWebsocketListener)) {
92
- try {
93
- this.adb.removeLogcatListener(this._logcatWebsocketListener);
94
- } catch (ign) {}
95
- this._logcatWebsocketListener = null;
101
+ log.info(
102
+ `Starting logcat broadcasting on web socket server ` +
103
+ `${JSON.stringify(server.address())} to ${pathname}`
104
+ );
105
+ // https://github.com/websockets/ws/blob/master/doc/ws.md
106
+ const wss = new WebSocket.Server({
107
+ noServer: true,
108
+ });
109
+ wss.on('connection', (ws, req) => {
110
+ if (req) {
111
+ const remoteIp = _.isEmpty(req.headers['x-forwarded-for'])
112
+ ? req.connection?.remoteAddress
113
+ : req.headers['x-forwarded-for'];
114
+ log.debug(`Established a new logcat listener web socket connection from ${remoteIp}`);
115
+ } else {
116
+ log.debug('Established a new logcat listener web socket connection');
96
117
  }
97
118
 
98
- let closeMsg = 'Logcat listener web socket is closed.';
99
- if (!_.isEmpty(code)) {
100
- closeMsg += ` Code: ${code}.`;
101
- }
102
- if (!_.isEmpty(reason)) {
103
- closeMsg += ` Reason: ${reason.toString()}.`;
119
+ if (_.isEmpty(this._logcatWebsocketListener)) {
120
+ this._logcatWebsocketListener = (logRecord) => {
121
+ if (ws?.readyState === WebSocket.OPEN) {
122
+ ws.send(logRecord.message);
123
+ }
124
+ };
104
125
  }
105
- log.debug(closeMsg);
126
+ adb.setLogcatListener(this._logcatWebsocketListener);
127
+
128
+ ws.on('close', (code, reason) => {
129
+ if (!_.isEmpty(this._logcatWebsocketListener)) {
130
+ try {
131
+ adb.removeLogcatListener(this._logcatWebsocketListener);
132
+ } catch (ign) {}
133
+ this._logcatWebsocketListener = undefined;
134
+ }
135
+
136
+ let closeMsg = 'Logcat listener web socket is closed.';
137
+ if (!_.isEmpty(code)) {
138
+ closeMsg += ` Code: ${code}.`;
139
+ }
140
+ if (!_.isEmpty(reason)) {
141
+ closeMsg += ` Reason: ${reason.toString()}.`;
142
+ }
143
+ log.debug(closeMsg);
144
+ });
106
145
  });
107
- });
108
- await this.server.addWebSocketHandler(pathname, wss);
109
- };
146
+ await server.addWebSocketHandler(
147
+ pathname,
148
+ /** @type {import('@appium/types').WSServer} */ (wss)
149
+ );
150
+ },
151
+ /**
152
+ * Stops the previously started logcat broadcasting wesocket server.
153
+ * This method will return immediately if no server is running.
154
+ */
155
+ async mobileStopLogsBroadcast() {
156
+ const pathname = WEBSOCKET_ENDPOINT(/** @type {string} */ (this.sessionId));
157
+ const server = /** @type {import('@appium/types').AppiumServer} */ (this.server);
158
+ if (_.isEmpty(await server.getWebSocketHandlers(pathname))) {
159
+ return;
160
+ }
110
161
 
111
- /**
112
- * Stops the previously started logcat broadcasting wesocket server.
113
- * This method will return immediately if no server is running.
114
- */
115
- commands.mobileStopLogsBroadcast = async function mobileStopLogsBroadcast () {
116
- const pathname = WEBSOCKET_ENDPOINT(this.sessionId);
117
- if (_.isEmpty(await this.server.getWebSocketHandlers(pathname))) {
118
- return;
119
- }
162
+ log.debug(
163
+ `Stopping logcat broadcasting on web socket server ` +
164
+ `${JSON.stringify(server.address())} to ${pathname}`
165
+ );
166
+ await server.removeWebSocketHandler(pathname);
167
+ },
120
168
 
121
- log.debug(`Stopping logcat broadcasting on web socket server ` +
122
- `${JSON.stringify(this.server.address())} to ${pathname}`);
123
- await this.server.removeWebSocketHandler(pathname);
124
- };
169
+ async getLogTypes() {
170
+ // XXX why doesn't `super` work here?
171
+ const nativeLogTypes = await BaseDriver.prototype.getLogTypes.call(this);
172
+ if (this.isWebContext()) {
173
+ const webLogTypes = /** @type {string[]} */ (
174
+ await /** @type {import('appium-chromedriver').Chromedriver} */ (
175
+ this.chromedriver
176
+ ).jwproxy.command('/log/types', 'GET')
177
+ );
178
+ return [...nativeLogTypes, ...webLogTypes];
179
+ }
180
+ return nativeLogTypes;
181
+ },
125
182
 
126
- commands.getLogTypes = async function getLogTypes () {
127
- const nativeLogTypes = await BaseDriver.prototype.getLogTypes.call(this);
128
- if (this.isWebContext()) {
129
- const webLogTypes = await this.chromedriver.jwproxy.command('/log/types', 'GET');
130
- return [...nativeLogTypes, ...webLogTypes];
131
- }
132
- return nativeLogTypes;
183
+ async getLog(logType) {
184
+ if (this.isWebContext() && !_.keys(this.supportedLogTypes).includes(logType)) {
185
+ return await /** @type {import('appium-chromedriver').Chromedriver} */ (
186
+ this.chromedriver
187
+ ).jwproxy.command('/log', 'POST', {type: logType});
188
+ }
189
+ // XXX why doesn't `super` work here?
190
+ return await BaseDriver.prototype.getLog.call(this, logType);
191
+ },
133
192
  };
134
193
 
135
- commands.getLog = async function getLog (logType) {
136
- if (this.isWebContext() && !_.keys(this.supportedLogTypes).includes(logType)) {
137
- return await this.chromedriver.jwproxy.command('/log', 'POST', {type: logType});
138
- }
139
- return await BaseDriver.prototype.getLog.call(this, logType);
140
- };
194
+ mixin(LogMixin);
195
+
196
+ export default LogMixin;
141
197
 
142
- Object.assign(extensions, commands, helpers);
143
- export { commands, helpers };
144
- export default extensions;
198
+ /**
199
+ * @typedef {import('appium-adb').ADB} ADB
200
+ */