@appium/base-driver 8.2.4 → 8.4.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.
Files changed (206) hide show
  1. package/build/lib/basedriver/capabilities.d.ts +80 -0
  2. package/build/lib/basedriver/capabilities.d.ts.map +1 -0
  3. package/build/lib/basedriver/capabilities.js +12 -13
  4. package/build/lib/basedriver/commands/event.d.ts +9 -0
  5. package/build/lib/basedriver/commands/event.d.ts.map +1 -0
  6. package/build/lib/basedriver/commands/event.js +21 -23
  7. package/build/lib/basedriver/commands/find.d.ts +11 -0
  8. package/build/lib/basedriver/commands/find.d.ts.map +1 -0
  9. package/build/lib/basedriver/commands/find.js +41 -43
  10. package/build/lib/basedriver/commands/index.d.ts +8 -0
  11. package/build/lib/basedriver/commands/index.d.ts.map +1 -0
  12. package/build/lib/basedriver/commands/index.js +17 -16
  13. package/build/lib/basedriver/commands/log.d.ts +12 -0
  14. package/build/lib/basedriver/commands/log.d.ts.map +1 -0
  15. package/build/lib/basedriver/commands/log.js +23 -30
  16. package/build/lib/basedriver/commands/session.d.ts +11 -0
  17. package/build/lib/basedriver/commands/session.d.ts.map +1 -0
  18. package/build/lib/basedriver/commands/session.js +21 -158
  19. package/build/lib/basedriver/commands/settings.d.ts +10 -0
  20. package/build/lib/basedriver/commands/settings.d.ts.map +1 -0
  21. package/build/lib/basedriver/commands/settings.js +18 -22
  22. package/build/lib/basedriver/commands/timeout.d.ts +8 -0
  23. package/build/lib/basedriver/commands/timeout.d.ts.map +1 -0
  24. package/build/lib/basedriver/commands/timeout.js +118 -144
  25. package/build/lib/basedriver/core.d.ts +235 -0
  26. package/build/lib/basedriver/core.d.ts.map +1 -0
  27. package/build/lib/basedriver/core.js +283 -0
  28. package/build/lib/basedriver/desired-caps.d.ts +5 -0
  29. package/build/lib/basedriver/desired-caps.d.ts.map +1 -0
  30. package/build/lib/basedriver/desired-caps.js +2 -4
  31. package/build/lib/basedriver/device-settings.d.ts +32 -0
  32. package/build/lib/basedriver/device-settings.d.ts.map +1 -0
  33. package/build/lib/basedriver/device-settings.js +33 -15
  34. package/build/lib/basedriver/driver.d.ts +83 -0
  35. package/build/lib/basedriver/driver.d.ts.map +1 -0
  36. package/build/lib/basedriver/driver.js +104 -257
  37. package/build/lib/basedriver/helpers.d.ts +132 -0
  38. package/build/lib/basedriver/helpers.d.ts.map +1 -0
  39. package/build/lib/basedriver/helpers.js +24 -10
  40. package/build/lib/basedriver/logger.d.ts +3 -0
  41. package/build/lib/basedriver/logger.d.ts.map +1 -0
  42. package/build/lib/basedriver/logger.js +2 -4
  43. package/build/lib/constants.d.ts +9 -0
  44. package/build/lib/constants.d.ts.map +1 -0
  45. package/build/lib/constants.js +2 -4
  46. package/build/lib/express/crash.d.ts +3 -0
  47. package/build/lib/express/crash.d.ts.map +1 -0
  48. package/build/lib/express/crash.js +2 -4
  49. package/build/lib/express/express-logging.d.ts +3 -0
  50. package/build/lib/express/express-logging.d.ts.map +1 -0
  51. package/build/lib/express/express-logging.js +3 -5
  52. package/build/lib/express/idempotency.d.ts +2 -0
  53. package/build/lib/express/idempotency.d.ts.map +1 -0
  54. package/build/lib/express/idempotency.js +3 -5
  55. package/build/lib/express/logger.d.ts +3 -0
  56. package/build/lib/express/logger.d.ts.map +1 -0
  57. package/build/lib/express/logger.js +2 -4
  58. package/build/lib/express/middleware.d.ts +9 -0
  59. package/build/lib/express/middleware.d.ts.map +1 -0
  60. package/build/lib/express/middleware.js +2 -4
  61. package/build/lib/express/server.d.ts +10 -0
  62. package/build/lib/express/server.d.ts.map +1 -0
  63. package/build/lib/express/server.js +2 -4
  64. package/build/lib/express/static.d.ts +6 -0
  65. package/build/lib/express/static.d.ts.map +1 -0
  66. package/build/lib/express/static.js +2 -4
  67. package/build/lib/express/websocket.d.ts +64 -0
  68. package/build/lib/express/websocket.d.ts.map +1 -0
  69. package/build/lib/express/websocket.js +2 -4
  70. package/build/lib/helpers/capabilities.d.ts +13 -0
  71. package/build/lib/helpers/capabilities.d.ts.map +1 -0
  72. package/build/lib/helpers/capabilities.js +77 -0
  73. package/build/lib/index.d.ts +183 -0
  74. package/build/lib/index.d.ts.map +1 -0
  75. package/build/lib/index.js +41 -25
  76. package/build/lib/jsonwp-proxy/protocol-converter.d.ts +48 -0
  77. package/build/lib/jsonwp-proxy/protocol-converter.d.ts.map +1 -0
  78. package/build/lib/jsonwp-proxy/protocol-converter.js +19 -15
  79. package/build/lib/jsonwp-proxy/proxy.d.ts +41 -0
  80. package/build/lib/jsonwp-proxy/proxy.d.ts.map +1 -0
  81. package/build/lib/jsonwp-proxy/proxy.js +20 -15
  82. package/build/lib/jsonwp-status/status.d.ts +159 -0
  83. package/build/lib/jsonwp-status/status.d.ts.map +1 -0
  84. package/build/lib/jsonwp-status/status.js +2 -4
  85. package/build/lib/protocol/errors.d.ts +310 -0
  86. package/build/lib/protocol/errors.d.ts.map +1 -0
  87. package/build/lib/protocol/errors.js +82 -5
  88. package/build/lib/protocol/helpers.d.ts +22 -0
  89. package/build/lib/protocol/helpers.d.ts.map +1 -0
  90. package/build/lib/protocol/helpers.js +2 -4
  91. package/build/lib/protocol/index.d.ts +16 -0
  92. package/build/lib/protocol/index.d.ts.map +1 -0
  93. package/build/lib/protocol/index.js +8 -10
  94. package/build/lib/protocol/protocol.d.ts +11 -0
  95. package/build/lib/protocol/protocol.d.ts.map +1 -0
  96. package/build/lib/protocol/protocol.js +38 -35
  97. package/build/lib/protocol/routes.d.ts +6 -0
  98. package/build/lib/protocol/routes.d.ts.map +1 -0
  99. package/build/lib/protocol/routes.js +84 -4
  100. package/build/lib/protocol/validators.d.ts +8 -0
  101. package/build/lib/protocol/validators.d.ts.map +1 -0
  102. package/build/lib/protocol/validators.js +2 -4
  103. package/build/test/basedriver/README.md +5 -0
  104. package/build/test/basedriver/driver-e2e-tests.js +2 -4
  105. package/build/test/basedriver/driver-tests.js +41 -19
  106. package/build/test/basedriver/index.js +2 -4
  107. package/build/test/e2e/basedriver/driver.e2e.spec.js +15 -0
  108. package/build/test/e2e/basedriver/helpers.e2e.spec.js +192 -0
  109. package/build/test/e2e/basedriver/websockets.e2e.spec.js +82 -0
  110. package/build/test/e2e/express/server.e2e.spec.js +159 -0
  111. package/build/test/e2e/jsonwp-proxy/proxy.e2e.spec.js +59 -0
  112. package/build/test/e2e/protocol/fake-driver.js +163 -0
  113. package/build/test/e2e/protocol/helpers.js +25 -0
  114. package/build/test/e2e/protocol/protocol.e2e.spec.js +1186 -0
  115. package/build/test/helpers.js +2 -4
  116. package/build/test/unit/basedriver/capabilities.spec.js +672 -0
  117. package/build/test/unit/basedriver/capability.spec.js +353 -0
  118. package/build/test/unit/basedriver/commands/event.spec.js +110 -0
  119. package/build/test/unit/basedriver/commands/log.spec.js +92 -0
  120. package/build/test/unit/basedriver/driver.spec.js +15 -0
  121. package/build/test/unit/basedriver/helpers.spec.js +151 -0
  122. package/build/test/unit/basedriver/timeout.spec.js +135 -0
  123. package/build/test/unit/express/server.spec.js +155 -0
  124. package/build/test/unit/express/static.spec.js +26 -0
  125. package/build/test/unit/jsonwp-proxy/mock-request.js +91 -0
  126. package/build/test/unit/jsonwp-proxy/protocol-converter.spec.js +171 -0
  127. package/build/test/unit/jsonwp-proxy/proxy.spec.js +292 -0
  128. package/build/test/unit/jsonwp-proxy/url.spec.js +165 -0
  129. package/build/test/unit/jsonwp-status/status.spec.js +34 -0
  130. package/build/test/unit/protocol/errors.spec.js +390 -0
  131. package/build/test/unit/protocol/routes.spec.js +80 -0
  132. package/build/test/unit/protocol/validator.spec.js +149 -0
  133. package/build/tsconfig.tsbuildinfo +1 -0
  134. package/lib/basedriver/capabilities.js +49 -10
  135. package/lib/basedriver/commands/event.js +49 -31
  136. package/lib/basedriver/commands/find.js +107 -45
  137. package/lib/basedriver/commands/index.js +25 -19
  138. package/lib/basedriver/commands/log.js +59 -34
  139. package/lib/basedriver/commands/session.js +39 -142
  140. package/lib/basedriver/commands/settings.js +32 -14
  141. package/lib/basedriver/commands/timeout.js +153 -154
  142. package/lib/basedriver/core.js +497 -0
  143. package/lib/basedriver/desired-caps.js +1 -1
  144. package/lib/basedriver/device-settings.js +57 -13
  145. package/lib/basedriver/driver.js +277 -375
  146. package/lib/basedriver/helpers.js +31 -13
  147. package/lib/express/express-logging.js +1 -1
  148. package/lib/express/idempotency.js +1 -1
  149. package/lib/helpers/capabilities.js +84 -0
  150. package/lib/index.js +17 -13
  151. package/lib/jsonwp-proxy/protocol-converter.js +14 -13
  152. package/lib/jsonwp-proxy/proxy.js +16 -12
  153. package/lib/protocol/errors.js +42 -42
  154. package/lib/protocol/index.js +4 -4
  155. package/lib/protocol/protocol.js +35 -32
  156. package/lib/protocol/routes.js +69 -1
  157. package/package.json +37 -24
  158. package/test/basedriver/README.md +5 -0
  159. package/test/basedriver/driver-e2e-tests.js +1 -1
  160. package/test/basedriver/driver-tests.js +43 -9
  161. package/build/lib/protocol/sessions-cache.js +0 -88
  162. package/build/test/basedriver/capabilities-specs.js +0 -632
  163. package/build/test/basedriver/capability-specs.js +0 -396
  164. package/build/test/basedriver/commands/event-specs.js +0 -112
  165. package/build/test/basedriver/commands/log-specs.js +0 -80
  166. package/build/test/basedriver/driver-e2e-specs.js +0 -17
  167. package/build/test/basedriver/driver-specs.js +0 -17
  168. package/build/test/basedriver/helpers-e2e-specs.js +0 -194
  169. package/build/test/basedriver/helpers-specs.js +0 -153
  170. package/build/test/basedriver/timeout-specs.js +0 -139
  171. package/build/test/basedriver/websockets-e2e-specs.js +0 -84
  172. package/build/test/express/server-e2e-specs.js +0 -156
  173. package/build/test/express/server-specs.js +0 -151
  174. package/build/test/express/static-specs.js +0 -23
  175. package/build/test/jsonwp-proxy/mock-request.js +0 -93
  176. package/build/test/jsonwp-proxy/protocol-converter-specs.js +0 -173
  177. package/build/test/jsonwp-proxy/proxy-e2e-specs.js +0 -61
  178. package/build/test/jsonwp-proxy/proxy-specs.js +0 -294
  179. package/build/test/jsonwp-proxy/url-specs.js +0 -167
  180. package/build/test/jsonwp-status/status-specs.js +0 -36
  181. package/build/test/protocol/errors-specs.js +0 -388
  182. package/build/test/protocol/fake-driver.js +0 -168
  183. package/build/test/protocol/helpers.js +0 -27
  184. package/build/test/protocol/protocol-e2e-specs.js +0 -1182
  185. package/build/test/protocol/routes-specs.js +0 -82
  186. package/build/test/protocol/validator-specs.js +0 -151
  187. package/index.d.ts +0 -386
  188. package/lib/protocol/sessions-cache.js +0 -74
  189. package/test/basedriver/capabilities-specs.js +0 -505
  190. package/test/basedriver/capability-specs.js +0 -409
  191. package/test/basedriver/commands/event-specs.js +0 -74
  192. package/test/basedriver/commands/log-specs.js +0 -70
  193. package/test/basedriver/driver-e2e-specs.js +0 -8
  194. package/test/basedriver/driver-specs.js +0 -8
  195. package/test/basedriver/fixtures/BadZippedApp.zip +0 -1
  196. package/test/basedriver/fixtures/FakeAndroidApp.apk +0 -1
  197. package/test/basedriver/fixtures/FakeAndroidApp.asd +0 -0
  198. package/test/basedriver/fixtures/FakeIOSApp.app +0 -1
  199. package/test/basedriver/fixtures/FakeIOSApp.app.zip +0 -0
  200. package/test/basedriver/fixtures/FakeIOSApp.ipa +0 -0
  201. package/test/basedriver/fixtures/custom-element-finder-bad.js +0 -5
  202. package/test/basedriver/fixtures/custom-element-finder.js +0 -29
  203. package/test/basedriver/helpers-e2e-specs.js +0 -187
  204. package/test/basedriver/helpers-specs.js +0 -137
  205. package/test/basedriver/timeout-specs.js +0 -133
  206. package/test/basedriver/websockets-e2e-specs.js +0 -75
@@ -1,168 +1,167 @@
1
- import log from '../logger';
2
- import { waitForCondition } from 'asyncbox';
1
+ // @ts-check
2
+
3
+ /* eslint-disable no-unused-vars */
4
+ /* eslint-disable require-await */
5
+ import {waitForCondition} from 'asyncbox';
3
6
  import _ from 'lodash';
4
- import { util } from '@appium/support';
5
- import { errors } from '../../protocol';
7
+ import {util} from '@appium/support';
8
+ import {errors} from '../../protocol';
6
9
 
10
+ const MIN_TIMEOUT = 0;
7
11
 
8
- let commands = {}, helpers = {}, extensions = {};
12
+ /**
13
+ * @param {import('../driver').BaseDriverBase} Base
14
+ * @returns {TimeoutBase}
15
+ */
16
+ export function TimeoutMixin (Base) {
17
+
18
+ /**
19
+ * @implements {ITimeoutCommands}
20
+ */
21
+ class TimeoutCommands extends Base {
22
+ async timeouts (type, ms, script, pageLoad, implicit) {
23
+ if (util.hasValue(type) && util.hasValue(ms)) {
24
+ this.log.debug(
25
+ `MJSONWP timeout arguments: ${JSON.stringify({type, ms})}}`,
26
+ );
27
+
28
+ switch (type) {
29
+ case 'command':
30
+ await this.newCommandTimeout(ms);
31
+ return;
32
+ case 'implicit':
33
+ await this.implicitWaitMJSONWP(ms);
34
+ return;
35
+ case 'page load':
36
+ await this.pageLoadTimeoutMJSONWP(ms);
37
+ return;
38
+ case 'script':
39
+ await this.scriptTimeoutMJSONWP(ms);
40
+ return;
41
+ default:
42
+ throw new Error(
43
+ `'${type}' type is not supported for MJSONWP timeout`,
44
+ );
45
+ }
46
+ }
9
47
 
10
- const MIN_TIMEOUT = 0;
48
+ // Otherwise assume it is W3C protocol
49
+ this.log.debug(
50
+ `W3C timeout argument: ${JSON.stringify({
51
+ script,
52
+ pageLoad,
53
+ implicit,
54
+ })}}`,
55
+ );
56
+ if (util.hasValue(script)) {
57
+ await this.scriptTimeoutW3C(script);
58
+ }
59
+ if (util.hasValue(pageLoad)) {
60
+ await this.pageLoadTimeoutW3C(pageLoad);
61
+ }
62
+ if (util.hasValue(implicit)) {
63
+ await this.implicitWaitW3C(implicit);
64
+ }
65
+ }
11
66
 
12
- commands.timeouts = async function timeouts (type, ms, script, pageLoad, implicit) {
13
- if (util.hasValue(type) && util.hasValue(ms)) {
14
- log.debug(`MJSONWP timeout arguments: ${JSON.stringify({type, ms})}}`);
15
-
16
- switch (type) {
17
- case 'command':
18
- await this.newCommandTimeout(ms);
19
- return;
20
- case 'implicit':
21
- await this.implicitWaitMJSONWP(ms);
22
- return;
23
- case 'page load':
24
- await this.pageLoadTimeoutMJSONWP(ms);
25
- return;
26
- case 'script':
27
- await this.scriptTimeoutMJSONWP(ms);
28
- return;
29
- default:
30
- throw new Error(`'${type}' type is not supported for MJSONWP timeout`);
67
+ async getTimeouts () {
68
+ return {
69
+ command: this.newCommandTimeoutMs,
70
+ implicit: this.implicitWaitMs,
71
+ };
31
72
  }
32
- }
33
73
 
34
- // Otherwise assume it is W3C protocol
35
- log.debug(`W3C timeout argument: ${JSON.stringify({script, pageLoad, implicit})}}`);
36
- if (util.hasValue(script)) {
37
- await this.scriptTimeoutW3C(script);
38
- }
39
- if (util.hasValue(pageLoad)) {
40
- await this.pageLoadTimeoutW3C(pageLoad);
41
- }
42
- if (util.hasValue(implicit)) {
43
- await this.implicitWaitW3C(implicit);
44
- }
45
- };
46
-
47
- commands.getTimeouts = async function getTimeouts () { // eslint-disable-line require-await
48
- return {
49
- command: this.newCommandTimeoutMs,
50
- implicit: this.implicitWaitMs,
51
- };
52
- };
53
-
54
- // implicit
55
- commands.implicitWaitW3C = async function implicitWaitW3C (ms) {
56
- await this.implicitWait(ms);
57
- };
58
-
59
- commands.implicitWaitMJSONWP = async function implicitWaitMJSONWP (ms) {
60
- await this.implicitWait(ms);
61
- };
62
-
63
- commands.implicitWait = async function implicitWait (ms) {
64
- await this.setImplicitWait(this.parseTimeoutArgument(ms));
65
- };
66
-
67
- helpers.setImplicitWait = function setImplicitWait (ms) { // eslint-disable-line require-await
68
- this.implicitWaitMs = ms;
69
- log.debug(`Set implicit wait to ${ms}ms`);
70
- if (this.managedDrivers && this.managedDrivers.length) {
71
- log.debug('Setting implicit wait on managed drivers');
72
- for (let driver of this.managedDrivers) {
73
- if (_.isFunction(driver.setImplicitWait)) {
74
- driver.setImplicitWait(ms);
74
+ // implicit
75
+ async implicitWaitW3C (ms) {
76
+ await this.implicitWait(ms);
77
+ }
78
+
79
+ async implicitWaitMJSONWP (ms) {
80
+ await this.implicitWait(ms);
81
+ }
82
+
83
+ async implicitWait (ms) {
84
+ await this.setImplicitWait(this.parseTimeoutArgument(ms));
85
+ }
86
+
87
+ // pageLoad
88
+ async pageLoadTimeoutW3C (ms) {
89
+ throw new errors.NotImplementedError('Not implemented yet for pageLoad.');
90
+ }
91
+
92
+ async pageLoadTimeoutMJSONWP (ms) {
93
+ throw new errors.NotImplementedError('Not implemented yet for pageLoad.');
94
+ }
95
+
96
+ // script
97
+ async scriptTimeoutW3C (ms) {
98
+ throw new errors.NotImplementedError('Not implemented yet for script.');
99
+ }
100
+
101
+ async scriptTimeoutMJSONWP (ms) {
102
+ throw new errors.NotImplementedError('Not implemented yet for script.');
103
+ }
104
+
105
+ // command
106
+ async newCommandTimeout (ms) {
107
+ this.setNewCommandTimeout(this.parseTimeoutArgument(ms));
108
+ }
109
+
110
+ setImplicitWait (ms) {
111
+ // eslint-disable-line require-await
112
+ this.implicitWaitMs = ms;
113
+ this.log.debug(`Set implicit wait to ${ms}ms`);
114
+ if (this.managedDrivers && this.managedDrivers.length) {
115
+ this.log.debug('Setting implicit wait on managed drivers');
116
+ for (let driver of this.managedDrivers) {
117
+ if (_.isFunction(driver.setImplicitWait)) {
118
+ driver.setImplicitWait(ms);
119
+ }
120
+ }
75
121
  }
76
122
  }
77
- }
78
- };
79
-
80
- // pageLoad
81
- // eslint-disable-next-line no-unused-vars
82
- commands.pageLoadTimeoutW3C = async function pageLoadTimeoutW3C (ms) { // eslint-disable-line require-await
83
- throw new errors.NotImplementedError('Not implemented yet for pageLoad.');
84
- };
85
-
86
- // eslint-disable-next-line no-unused-vars
87
- commands.pageLoadTimeoutMJSONWP = async function pageLoadTimeoutMJSONWP (ms) { // eslint-disable-line require-await
88
- throw new errors.NotImplementedError('Not implemented yet for pageLoad.');
89
- };
90
-
91
- // script
92
- // eslint-disable-next-line no-unused-vars
93
- commands.scriptTimeoutW3C = async function scriptTimeoutW3C (ms) { // eslint-disable-line require-await
94
- throw new errors.NotImplementedError('Not implemented yet for script.');
95
- };
96
-
97
- // eslint-disable-next-line no-unused-vars
98
- commands.scriptTimeoutMJSONWP = async function scriptTimeoutMJSONWP (ms) { // eslint-disable-line require-await
99
- throw new errors.NotImplementedError('Not implemented yet for script.');
100
- };
101
-
102
- // command
103
- commands.newCommandTimeout = async function newCommandTimeout (ms) { // eslint-disable-line require-await
104
- this.setNewCommandTimeout(this.parseTimeoutArgument(ms));
105
- };
106
-
107
- helpers.setNewCommandTimeout = function setNewCommandTimeout (ms) {
108
- this.newCommandTimeoutMs = ms;
109
- log.debug(`Set new command timeout to ${ms}ms`);
110
- if (this.managedDrivers && this.managedDrivers.length) {
111
- log.debug('Setting new command timeout on managed drivers');
112
- for (let driver of this.managedDrivers) {
113
- if (_.isFunction(driver.setNewCommandTimeout)) {
114
- driver.setNewCommandTimeout(ms);
123
+
124
+ setNewCommandTimeout (ms) {
125
+ this.newCommandTimeoutMs = ms;
126
+ this.log.debug(`Set new command timeout to ${ms}ms`);
127
+ if (this.managedDrivers && this.managedDrivers.length) {
128
+ this.log.debug('Setting new command timeout on managed drivers');
129
+ for (let driver of this.managedDrivers) {
130
+ if (_.isFunction(driver.setNewCommandTimeout)) {
131
+ driver.setNewCommandTimeout(ms);
132
+ }
133
+ }
115
134
  }
116
135
  }
117
- }
118
- };
119
136
 
120
- helpers.clearNewCommandTimeout = function clearNewCommandTimeout () {
121
- if (this.noCommandTimer) {
122
- clearTimeout(this.noCommandTimer);
123
- this.noCommandTimer = null;
124
- }
125
- };
126
-
127
- helpers.startNewCommandTimeout = function startNewCommandTimeout () {
128
- // make sure there are no rogue timeouts
129
- this.clearNewCommandTimeout();
130
-
131
- // if command timeout is 0, it is disabled
132
- if (!this.newCommandTimeoutMs) return; // eslint-disable-line curly
133
-
134
- this.noCommandTimer = setTimeout(async () => {
135
- log.warn(`Shutting down because we waited ` +
136
- `${this.newCommandTimeoutMs / 1000.0} seconds for a command`);
137
- const errorMessage = `New Command Timeout of ` +
138
- `${this.newCommandTimeoutMs / 1000.0} seconds ` +
139
- `expired. Try customizing the timeout using the ` +
140
- `'newCommandTimeout' desired capability`;
141
- await this.startUnexpectedShutdown(new Error(errorMessage));
142
- }, this.newCommandTimeoutMs);
143
- };
144
-
145
- helpers.implicitWaitForCondition = async function implicitWaitForCondition (condFn) {
146
- log.debug(`Waiting up to ${this.implicitWaitMs} ms for condition`);
147
- let wrappedCondFn = async (...args) => {
148
- // reset command timeout
149
- this.clearNewCommandTimeout();
150
-
151
- return await condFn(...args);
152
- };
153
- return await waitForCondition(wrappedCondFn, {
154
- waitMs: this.implicitWaitMs, intervalMs: 500, logger: log
155
- });
156
- };
157
-
158
- helpers.parseTimeoutArgument = function parseTimeoutArgument (ms) {
159
- let duration = parseInt(ms, 10);
160
- if (_.isNaN(duration) || duration < MIN_TIMEOUT) {
161
- throw new errors.UnknownError(`Invalid timeout value '${ms}'`);
137
+ async implicitWaitForCondition (condFn) {
138
+ this.log.debug(`Waiting up to ${this.implicitWaitMs} ms for condition`);
139
+ let wrappedCondFn = async (...args) => {
140
+ // reset command timeout
141
+ await this.clearNewCommandTimeout();
142
+
143
+ return await condFn(...args);
144
+ };
145
+ return await waitForCondition(wrappedCondFn, {
146
+ waitMs: this.implicitWaitMs,
147
+ intervalMs: 500,
148
+ logger: this.log,
149
+ });
150
+ }
151
+
152
+ parseTimeoutArgument (ms) {
153
+ let duration = parseInt(ms, 10);
154
+ if (_.isNaN(duration) || duration < MIN_TIMEOUT) {
155
+ throw new errors.UnknownError(`Invalid timeout value '${ms}'`);
156
+ }
157
+ return duration;
158
+ }
162
159
  }
163
- return duration;
164
- };
165
160
 
166
- Object.assign(extensions, commands, helpers);
167
- export { commands, helpers };
168
- export default extensions;
161
+ return TimeoutCommands;
162
+ }
163
+
164
+ /**
165
+ * @typedef {import('@appium/types').TimeoutCommands} ITimeoutCommands
166
+ * @typedef {import('../driver').BaseDriverBase<ITimeoutCommands>} TimeoutBase
167
+ */