@appium/base-driver 8.5.2 → 8.5.5

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 (141) hide show
  1. package/build/lib/basedriver/capabilities.d.ts.map +1 -1
  2. package/build/lib/basedriver/capabilities.js +1 -1
  3. package/build/lib/basedriver/commands/event.js +1 -1
  4. package/build/lib/basedriver/commands/find.d.ts.map +1 -1
  5. package/build/lib/basedriver/commands/find.js +1 -1
  6. package/build/lib/basedriver/commands/index.js +1 -1
  7. package/build/lib/basedriver/commands/log.d.ts.map +1 -1
  8. package/build/lib/basedriver/commands/log.js +1 -1
  9. package/build/lib/basedriver/commands/session.js +1 -1
  10. package/build/lib/basedriver/commands/settings.d.ts.map +1 -1
  11. package/build/lib/basedriver/commands/settings.js +1 -1
  12. package/build/lib/basedriver/commands/timeout.d.ts.map +1 -1
  13. package/build/lib/basedriver/commands/timeout.js +1 -1
  14. package/build/lib/basedriver/core.d.ts +120 -139
  15. package/build/lib/basedriver/core.d.ts.map +1 -1
  16. package/build/lib/basedriver/core.js +1 -49
  17. package/build/lib/basedriver/desired-caps.d.ts +5 -2
  18. package/build/lib/basedriver/desired-caps.d.ts.map +1 -1
  19. package/build/lib/basedriver/desired-caps.js +14 -18
  20. package/build/lib/basedriver/device-settings.d.ts +9 -9
  21. package/build/lib/basedriver/device-settings.d.ts.map +1 -1
  22. package/build/lib/basedriver/device-settings.js +4 -4
  23. package/build/lib/basedriver/driver.d.ts +43 -38
  24. package/build/lib/basedriver/driver.d.ts.map +1 -1
  25. package/build/lib/basedriver/driver.js +58 -11
  26. package/build/lib/basedriver/helpers.d.ts +8 -3
  27. package/build/lib/basedriver/helpers.d.ts.map +1 -1
  28. package/build/lib/basedriver/helpers.js +4 -6
  29. package/build/lib/basedriver/logger.d.ts +1 -1
  30. package/build/lib/basedriver/logger.d.ts.map +1 -1
  31. package/build/lib/basedriver/logger.js +1 -1
  32. package/build/lib/constants.js +1 -1
  33. package/build/lib/express/crash.d.ts.map +1 -1
  34. package/build/lib/express/crash.js +1 -1
  35. package/build/lib/express/express-logging.d.ts.map +1 -1
  36. package/build/lib/express/express-logging.js +1 -1
  37. package/build/lib/express/idempotency.js +1 -1
  38. package/build/lib/express/logger.d.ts +1 -1
  39. package/build/lib/express/logger.d.ts.map +1 -1
  40. package/build/lib/express/logger.js +1 -1
  41. package/build/lib/express/middleware.d.ts.map +1 -1
  42. package/build/lib/express/middleware.js +1 -1
  43. package/build/lib/express/server.d.ts +21 -0
  44. package/build/lib/express/server.d.ts.map +1 -1
  45. package/build/lib/express/server.js +4 -9
  46. package/build/lib/express/static.d.ts.map +1 -1
  47. package/build/lib/express/static.js +2 -2
  48. package/build/lib/express/websocket.d.ts +14 -11
  49. package/build/lib/express/websocket.d.ts.map +1 -1
  50. package/build/lib/express/websocket.js +2 -2
  51. package/build/lib/helpers/capabilities.d.ts.map +1 -1
  52. package/build/lib/helpers/capabilities.js +1 -1
  53. package/build/lib/index.d.ts +2 -1
  54. package/build/lib/index.js +7 -1
  55. package/build/lib/jsonwp-proxy/protocol-converter.d.ts.map +1 -1
  56. package/build/lib/jsonwp-proxy/protocol-converter.js +2 -2
  57. package/build/lib/jsonwp-proxy/proxy.d.ts +30 -5
  58. package/build/lib/jsonwp-proxy/proxy.d.ts.map +1 -1
  59. package/build/lib/jsonwp-proxy/proxy.js +20 -4
  60. package/build/lib/jsonwp-status/status.d.ts.map +1 -1
  61. package/build/lib/jsonwp-status/status.js +2 -2
  62. package/build/lib/protocol/errors.d.ts +17 -8
  63. package/build/lib/protocol/errors.d.ts.map +1 -1
  64. package/build/lib/protocol/errors.js +9 -5
  65. package/build/lib/protocol/helpers.js +1 -1
  66. package/build/lib/protocol/index.js +1 -1
  67. package/build/lib/protocol/protocol.d.ts.map +1 -1
  68. package/build/lib/protocol/protocol.js +1 -1
  69. package/build/lib/protocol/routes.d.ts +17 -3
  70. package/build/lib/protocol/routes.d.ts.map +1 -1
  71. package/build/lib/protocol/routes.js +1 -1
  72. package/build/lib/protocol/validators.js +1 -1
  73. package/build/test/basedriver/driver-e2e-tests.js +1 -1
  74. package/build/test/basedriver/driver-tests.js +1 -1
  75. package/build/test/basedriver/index.js +1 -1
  76. package/build/test/e2e/basedriver/driver.e2e.spec.js +1 -1
  77. package/build/test/e2e/basedriver/helpers.e2e.spec.js +1 -1
  78. package/build/test/e2e/basedriver/websockets.e2e.spec.js +1 -1
  79. package/build/test/e2e/express/server.e2e.spec.js +1 -1
  80. package/build/test/e2e/jsonwp-proxy/proxy.e2e.spec.js +1 -1
  81. package/build/test/e2e/protocol/fake-driver.js +1 -1
  82. package/build/test/e2e/protocol/helpers.js +1 -1
  83. package/build/test/e2e/protocol/protocol.e2e.spec.js +13 -13
  84. package/build/test/helpers.js +1 -1
  85. package/build/test/unit/basedriver/capabilities.spec.js +12 -12
  86. package/build/test/unit/basedriver/capability.spec.js +15 -15
  87. package/build/test/unit/basedriver/commands/event.spec.js +1 -1
  88. package/build/test/unit/basedriver/commands/log.spec.js +1 -1
  89. package/build/test/unit/basedriver/device-settings.spec.js +1 -1
  90. package/build/test/unit/basedriver/driver.spec.js +1 -1
  91. package/build/test/unit/basedriver/helpers.spec.js +33 -33
  92. package/build/test/unit/basedriver/timeout.spec.js +1 -1
  93. package/build/test/unit/express/server.spec.js +1 -1
  94. package/build/test/unit/express/static.spec.js +2 -2
  95. package/build/test/unit/jsonwp-proxy/mock-request.js +1 -1
  96. package/build/test/unit/jsonwp-proxy/protocol-converter.spec.js +1 -1
  97. package/build/test/unit/jsonwp-proxy/proxy.spec.js +2 -2
  98. package/build/test/unit/jsonwp-proxy/url.spec.js +1 -1
  99. package/build/test/unit/jsonwp-status/status.spec.js +1 -1
  100. package/build/test/unit/protocol/errors.spec.js +1 -1
  101. package/build/test/unit/protocol/routes.spec.js +1 -1
  102. package/build/test/unit/protocol/validator.spec.js +1 -1
  103. package/build/tsconfig.tsbuildinfo +1 -1
  104. package/lib/basedriver/capabilities.js +95 -47
  105. package/lib/basedriver/commands/event.js +4 -4
  106. package/lib/basedriver/commands/find.js +12 -26
  107. package/lib/basedriver/commands/index.js +7 -7
  108. package/lib/basedriver/commands/log.js +5 -7
  109. package/lib/basedriver/commands/session.js +3 -3
  110. package/lib/basedriver/commands/settings.js +3 -5
  111. package/lib/basedriver/commands/timeout.js +18 -23
  112. package/lib/basedriver/core.js +150 -229
  113. package/lib/basedriver/desired-caps.js +30 -29
  114. package/lib/basedriver/device-settings.js +21 -20
  115. package/lib/basedriver/driver.js +131 -96
  116. package/lib/basedriver/helpers.js +124 -81
  117. package/lib/basedriver/logger.js +1 -1
  118. package/lib/constants.js +2 -6
  119. package/lib/express/crash.js +4 -6
  120. package/lib/express/express-logging.js +26 -24
  121. package/lib/express/idempotency.js +16 -16
  122. package/lib/express/logger.js +1 -1
  123. package/lib/express/middleware.js +49 -33
  124. package/lib/express/server.js +68 -44
  125. package/lib/express/static.js +11 -12
  126. package/lib/express/websocket.js +26 -16
  127. package/lib/helpers/capabilities.js +11 -16
  128. package/lib/index.js +50 -33
  129. package/lib/jsonwp-proxy/protocol-converter.js +85 -69
  130. package/lib/jsonwp-proxy/proxy.js +116 -53
  131. package/lib/jsonwp-status/status.js +36 -29
  132. package/lib/protocol/errors.js +469 -292
  133. package/lib/protocol/helpers.js +5 -8
  134. package/lib/protocol/index.js +22 -15
  135. package/lib/protocol/protocol.js +103 -55
  136. package/lib/protocol/routes.js +430 -273
  137. package/lib/protocol/validators.js +5 -5
  138. package/package.json +9 -11
  139. package/test/basedriver/driver-e2e-tests.js +92 -66
  140. package/test/basedriver/driver-tests.js +90 -33
  141. package/test/basedriver/index.js +1 -1
@@ -1,202 +1,241 @@
1
1
  // @ts-check
2
2
 
3
3
  import _ from 'lodash';
4
- import { util } from '@appium/support';
5
- import { PROTOCOLS, DEFAULT_BASE_PATH } from '../constants';
6
-
4
+ import {util} from '@appium/support';
5
+ import {PROTOCOLS, DEFAULT_BASE_PATH} from '../constants';
7
6
 
8
7
  const SET_ALERT_TEXT_PAYLOAD_PARAMS = {
9
- validate: (jsonObj) => (!util.hasValue(jsonObj.value) && !util.hasValue(jsonObj.text)) &&
10
- 'either "text" or "value" must be set',
8
+ validate: (jsonObj) =>
9
+ !util.hasValue(jsonObj.value) &&
10
+ !util.hasValue(jsonObj.text) &&
11
+ 'either "text" or "value" must be set',
11
12
  optional: ['value', 'text'],
12
13
  // Prefer 'value' since it's more backward-compatible.
13
14
  makeArgs: (jsonObj) => [jsonObj.value || jsonObj.text],
14
15
  };
15
16
 
16
- // define the routes, mapping of HTTP methods to particular driver commands,
17
- // and any parameters that are expected in a request
18
- // parameters can be `required` or `optional`
19
- /** @type {import('@appium/types').MethodMap} */
17
+ /**
18
+ * define the routes, mapping of HTTP methods to particular driver commands, and
19
+ * any parameters that are expected in a request parameters can be `required` or
20
+ * `optional`
21
+ * @type {MethodMap}
22
+ */
20
23
  const METHOD_MAP = {
21
24
  '/status': {
22
- GET: {command: 'getStatus'}
25
+ GET: {command: 'getStatus'},
23
26
  },
24
27
  '/session': {
25
- POST: {command: 'createSession', payloadParams: {
26
- validate: (jsonObj) => (!jsonObj.capabilities && !jsonObj.desiredCapabilities) && 'we require one of "desiredCapabilities" or "capabilities" object',
27
- optional: ['desiredCapabilities', 'requiredCapabilities', 'capabilities']}}
28
+ POST: {
29
+ command: 'createSession',
30
+ payloadParams: {
31
+ validate: (jsonObj) =>
32
+ !jsonObj.capabilities &&
33
+ !jsonObj.desiredCapabilities &&
34
+ 'we require one of "desiredCapabilities" or "capabilities" object',
35
+ optional: ['desiredCapabilities', 'requiredCapabilities', 'capabilities'],
36
+ },
37
+ },
28
38
  },
29
39
  '/sessions': {
30
- GET: {command: 'getSessions'}
40
+ GET: {command: 'getSessions'},
31
41
  },
32
42
  '/session/:sessionId': {
33
43
  GET: {command: 'getSession'},
34
- DELETE: {command: 'deleteSession'}
44
+ DELETE: {command: 'deleteSession'},
35
45
  },
36
46
  '/session/:sessionId/timeouts': {
37
47
  GET: {command: 'getTimeouts'}, // W3C route
38
- POST: {command: 'timeouts', payloadParams: {
39
- validate: (jsonObj, protocolName) => {
40
- if (protocolName === PROTOCOLS.W3C) {
41
- if (!util.hasValue(jsonObj.script) && !util.hasValue(jsonObj.pageLoad) && !util.hasValue(jsonObj.implicit)) {
42
- return 'W3C protocol expects any of script, pageLoad or implicit to be set';
43
- }
44
- } else {
45
- // MJSONWP
46
- if (!util.hasValue(jsonObj.type) || !util.hasValue(jsonObj.ms)) {
47
- return 'MJSONWP protocol requires type and ms';
48
+ POST: {
49
+ command: 'timeouts',
50
+ payloadParams: {
51
+ validate: (jsonObj, protocolName) => {
52
+ if (protocolName === PROTOCOLS.W3C) {
53
+ if (
54
+ !util.hasValue(jsonObj.script) &&
55
+ !util.hasValue(jsonObj.pageLoad) &&
56
+ !util.hasValue(jsonObj.implicit)
57
+ ) {
58
+ return 'W3C protocol expects any of script, pageLoad or implicit to be set';
59
+ }
60
+ } else {
61
+ // MJSONWP
62
+ if (!util.hasValue(jsonObj.type) || !util.hasValue(jsonObj.ms)) {
63
+ return 'MJSONWP protocol requires type and ms';
64
+ }
48
65
  }
49
- }
66
+ },
67
+ optional: ['type', 'ms', 'script', 'pageLoad', 'implicit'],
50
68
  },
51
- optional: ['type', 'ms', 'script', 'pageLoad', 'implicit'],
52
- }}
69
+ },
53
70
  },
54
71
  '/session/:sessionId/timeouts/async_script': {
55
- POST: {command: 'asyncScriptTimeout', payloadParams: {required: ['ms']}}
72
+ POST: {command: 'asyncScriptTimeout', payloadParams: {required: ['ms']}},
56
73
  },
57
74
  '/session/:sessionId/timeouts/implicit_wait': {
58
- POST: {command: 'implicitWait', payloadParams: {required: ['ms']}}
75
+ POST: {command: 'implicitWait', payloadParams: {required: ['ms']}},
59
76
  },
60
77
  // JSONWP
61
78
  '/session/:sessionId/window_handle': {
62
- GET: {command: 'getWindowHandle'}
79
+ GET: {command: 'getWindowHandle'},
63
80
  },
64
81
  // W3C
65
82
  '/session/:sessionId/window/handle': {
66
- GET: {command: 'getWindowHandle'}
83
+ GET: {command: 'getWindowHandle'},
67
84
  },
68
85
  // JSONWP
69
86
  '/session/:sessionId/window_handles': {
70
- GET: {command: 'getWindowHandles'}
87
+ GET: {command: 'getWindowHandles'},
71
88
  },
72
89
  // W3C
73
90
  '/session/:sessionId/window/handles': {
74
- GET: {command: 'getWindowHandles'}
91
+ GET: {command: 'getWindowHandles'},
75
92
  },
76
93
  '/session/:sessionId/url': {
77
94
  GET: {command: 'getUrl'},
78
- POST: {command: 'setUrl', payloadParams: {required: ['url']}}
95
+ POST: {command: 'setUrl', payloadParams: {required: ['url']}},
79
96
  },
80
97
  '/session/:sessionId/forward': {
81
- POST: {command: 'forward'}
98
+ POST: {command: 'forward'},
82
99
  },
83
100
  '/session/:sessionId/back': {
84
- POST: {command: 'back'}
101
+ POST: {command: 'back'},
85
102
  },
86
103
  '/session/:sessionId/refresh': {
87
- POST: {command: 'refresh'}
104
+ POST: {command: 'refresh'},
88
105
  },
89
106
  // MJSONWP
90
107
  '/session/:sessionId/execute': {
91
- POST: {command: 'execute', payloadParams: {required: ['script', 'args']}}
108
+ POST: {command: 'execute', payloadParams: {required: ['script', 'args']}},
92
109
  },
93
110
  // MJSONWP
94
111
  '/session/:sessionId/execute_async': {
95
- POST: {command: 'executeAsync', payloadParams: {required: ['script', 'args']}}
112
+ POST: {
113
+ command: 'executeAsync',
114
+ payloadParams: {required: ['script', 'args']},
115
+ },
96
116
  },
97
117
  '/session/:sessionId/screenshot': {
98
- GET: {command: 'getScreenshot'}
118
+ GET: {command: 'getScreenshot'},
99
119
  },
100
120
  '/session/:sessionId/ime/available_engines': {
101
- GET: {command: 'availableIMEEngines'}
121
+ GET: {command: 'availableIMEEngines'},
102
122
  },
103
123
  '/session/:sessionId/ime/active_engine': {
104
- GET: {command: 'getActiveIMEEngine'}
124
+ GET: {command: 'getActiveIMEEngine'},
105
125
  },
106
126
  '/session/:sessionId/ime/activated': {
107
- GET: {command: 'isIMEActivated'}
127
+ GET: {command: 'isIMEActivated'},
108
128
  },
109
129
  '/session/:sessionId/ime/deactivate': {
110
- POST: {command: 'deactivateIMEEngine'}
130
+ POST: {command: 'deactivateIMEEngine'},
111
131
  },
112
132
  '/session/:sessionId/ime/activate': {
113
- POST: {command: 'activateIMEEngine', payloadParams: {required: ['engine']}}
133
+ POST: {command: 'activateIMEEngine', payloadParams: {required: ['engine']}},
114
134
  },
115
135
  '/session/:sessionId/frame': {
116
- POST: {command: 'setFrame', payloadParams: {required: ['id']}}
136
+ POST: {command: 'setFrame', payloadParams: {required: ['id']}},
117
137
  },
118
138
  '/session/:sessionId/frame/parent': {
119
- POST: {}
139
+ POST: {},
120
140
  },
121
141
  '/session/:sessionId/window': {
122
142
  GET: {command: 'getWindowHandle'},
123
- POST: {command: 'setWindow', payloadParams: {
124
- optional: ['name', 'handle'],
125
- // Return both values to match W3C and JSONWP protocols
126
- makeArgs: (jsonObj) => {
127
- if (util.hasValue(jsonObj.handle) && !util.hasValue(jsonObj.name)) {
128
- return [jsonObj.handle, jsonObj.handle];
129
- }
130
- if (util.hasValue(jsonObj.name) && !util.hasValue(jsonObj.handle)) {
131
- return [jsonObj.name, jsonObj.name];
132
- }
133
- return [jsonObj.name, jsonObj.handle];
143
+ POST: {
144
+ command: 'setWindow',
145
+ payloadParams: {
146
+ optional: ['name', 'handle'],
147
+ // Return both values to match W3C and JSONWP protocols
148
+ makeArgs: (jsonObj) => {
149
+ if (util.hasValue(jsonObj.handle) && !util.hasValue(jsonObj.name)) {
150
+ return [jsonObj.handle, jsonObj.handle];
151
+ }
152
+ if (util.hasValue(jsonObj.name) && !util.hasValue(jsonObj.handle)) {
153
+ return [jsonObj.name, jsonObj.name];
154
+ }
155
+ return [jsonObj.name, jsonObj.handle];
156
+ },
157
+ validate: (jsonObj) =>
158
+ !util.hasValue(jsonObj.name) &&
159
+ !util.hasValue(jsonObj.handle) &&
160
+ 'we require one of "name" or "handle" to be set',
134
161
  },
135
- validate: (jsonObj) => (!util.hasValue(jsonObj.name) && !util.hasValue(jsonObj.handle))
136
- && 'we require one of "name" or "handle" to be set',
137
- }},
138
- DELETE: {command: 'closeWindow'}
162
+ },
163
+ DELETE: {command: 'closeWindow'},
139
164
  },
140
165
  '/session/:sessionId/window/:windowhandle/size': {
141
166
  GET: {command: 'getWindowSize'},
142
- POST: {}
167
+ POST: {},
143
168
  },
144
169
  '/session/:sessionId/window/:windowhandle/position': {
145
170
  POST: {},
146
- GET: {}
171
+ GET: {},
147
172
  },
148
173
  '/session/:sessionId/window/:windowhandle/maximize': {
149
- POST: {command: 'maximizeWindow'}
174
+ POST: {command: 'maximizeWindow'},
150
175
  },
151
176
  '/session/:sessionId/cookie': {
152
177
  GET: {command: 'getCookies'},
153
178
  POST: {command: 'setCookie', payloadParams: {required: ['cookie']}},
154
- DELETE: {command: 'deleteCookies'}
179
+ DELETE: {command: 'deleteCookies'},
155
180
  },
156
181
  '/session/:sessionId/cookie/:name': {
157
182
  GET: {command: 'getCookie'},
158
- DELETE: {command: 'deleteCookie'}
183
+ DELETE: {command: 'deleteCookie'},
159
184
  },
160
185
  '/session/:sessionId/source': {
161
- GET: {command: 'getPageSource'}
186
+ GET: {command: 'getPageSource'},
162
187
  },
163
188
  '/session/:sessionId/title': {
164
- GET: {command: 'title'}
189
+ GET: {command: 'title'},
165
190
  },
166
191
  '/session/:sessionId/element': {
167
- POST: {command: 'findElement', payloadParams: {required: ['using', 'value']}}
192
+ POST: {
193
+ command: 'findElement',
194
+ payloadParams: {required: ['using', 'value']},
195
+ },
168
196
  },
169
197
  '/session/:sessionId/elements': {
170
- POST: {command: 'findElements', payloadParams: {required: ['using', 'value']}}
198
+ POST: {
199
+ command: 'findElements',
200
+ payloadParams: {required: ['using', 'value']},
201
+ },
171
202
  },
172
203
  '/session/:sessionId/element/active': {
173
204
  GET: {command: 'active'}, // W3C: https://w3c.github.io/webdriver/webdriver-spec.html#dfn-get-active-element
174
- POST: {command: 'active'}
205
+ POST: {command: 'active'},
175
206
  },
176
207
  '/session/:sessionId/element/:elementId': {
177
- GET: {}
208
+ GET: {},
178
209
  },
179
210
  '/session/:sessionId/element/:elementId/element': {
180
- POST: {command: 'findElementFromElement', payloadParams: {required: ['using', 'value']}}
211
+ POST: {
212
+ command: 'findElementFromElement',
213
+ payloadParams: {required: ['using', 'value']},
214
+ },
181
215
  },
182
216
  '/session/:sessionId/element/:elementId/elements': {
183
- POST: {command: 'findElementsFromElement', payloadParams: {required: ['using', 'value']}}
217
+ POST: {
218
+ command: 'findElementsFromElement',
219
+ payloadParams: {required: ['using', 'value']},
220
+ },
184
221
  },
185
222
  '/session/:sessionId/element/:elementId/click': {
186
- POST: {command: 'click'}
223
+ POST: {command: 'click'},
187
224
  },
188
225
  '/session/:sessionId/element/:elementId/submit': {
189
- POST: {command: 'submit'}
226
+ POST: {command: 'submit'},
190
227
  },
191
228
  '/session/:sessionId/element/:elementId/text': {
192
- GET: {command: 'getText'}
229
+ GET: {command: 'getText'},
193
230
  },
194
231
  '/session/:sessionId/element/:elementId/value': {
195
232
  POST: {
196
233
  command: 'setValue',
197
234
  payloadParams: {
198
- validate: (jsonObj) => (!util.hasValue(jsonObj.value) && !util.hasValue(jsonObj.text)) &&
199
- 'we require one of "text" or "value" params',
235
+ validate: (jsonObj) =>
236
+ !util.hasValue(jsonObj.value) &&
237
+ !util.hasValue(jsonObj.text) &&
238
+ 'we require one of "text" or "value" params',
200
239
  optional: ['value', 'text'],
201
240
  // override the default argument constructor because of the special
202
241
  // logic here. Basically we want to accept either a value (old JSONWP)
@@ -204,151 +243,168 @@ const METHOD_MAP = {
204
243
  // command (not both). Prefer 'value' since it's more
205
244
  // backward-compatible.
206
245
  makeArgs: (jsonObj) => [jsonObj.value || jsonObj.text],
207
- }
208
- }
246
+ },
247
+ },
209
248
  },
210
249
  '/session/:sessionId/keys': {
211
- POST: {command: 'keys', payloadParams: {required: ['value']}}
250
+ POST: {command: 'keys', payloadParams: {required: ['value']}},
212
251
  },
213
252
  '/session/:sessionId/element/:elementId/name': {
214
- GET: {command: 'getName'}
253
+ GET: {command: 'getName'},
215
254
  },
216
255
  '/session/:sessionId/element/:elementId/clear': {
217
- POST: {command: 'clear'}
256
+ POST: {command: 'clear'},
218
257
  },
219
258
  '/session/:sessionId/element/:elementId/selected': {
220
- GET: {command: 'elementSelected'}
259
+ GET: {command: 'elementSelected'},
221
260
  },
222
261
  '/session/:sessionId/element/:elementId/enabled': {
223
- GET: {command: 'elementEnabled'}
262
+ GET: {command: 'elementEnabled'},
224
263
  },
225
264
  '/session/:sessionId/element/:elementId/attribute/:name': {
226
- GET: {command: 'getAttribute'}
265
+ GET: {command: 'getAttribute'},
227
266
  },
228
267
  '/session/:sessionId/element/:elementId/equals/:otherId': {
229
- GET: {command: 'equalsElement'}
268
+ GET: {command: 'equalsElement'},
230
269
  },
231
270
  '/session/:sessionId/element/:elementId/displayed': {
232
- GET: {command: 'elementDisplayed'}
271
+ GET: {command: 'elementDisplayed'},
233
272
  },
234
273
  '/session/:sessionId/element/:elementId/location': {
235
- GET: {command: 'getLocation'}
274
+ GET: {command: 'getLocation'},
236
275
  },
237
276
  '/session/:sessionId/element/:elementId/location_in_view': {
238
- GET: {command: 'getLocationInView'}
277
+ GET: {command: 'getLocationInView'},
239
278
  },
240
279
  '/session/:sessionId/element/:elementId/size': {
241
- GET: {command: 'getSize'}
280
+ GET: {command: 'getSize'},
242
281
  },
243
282
  '/session/:sessionId/element/:elementId/shadow': {
244
- GET: {command: 'elementShadowRoot'}
283
+ GET: {command: 'elementShadowRoot'},
245
284
  },
246
285
  '/session/:sessionId/shadow/:shadowId/element': {
247
- POST: {command: 'findElementFromShadowRoot', payloadParams: {required: ['using', 'value']}}
286
+ POST: {
287
+ command: 'findElementFromShadowRoot',
288
+ payloadParams: {required: ['using', 'value']},
289
+ },
248
290
  },
249
291
  '/session/:sessionId/shadow/:shadowId/elements': {
250
- POST: {command: 'findElementsFromShadowRoot', payloadParams: {required: ['using', 'value']}}
292
+ POST: {
293
+ command: 'findElementsFromShadowRoot',
294
+ payloadParams: {required: ['using', 'value']},
295
+ },
251
296
  },
252
297
  '/session/:sessionId/element/:elementId/css/:propertyName': {
253
- GET: {command: 'getCssProperty'}
298
+ GET: {command: 'getCssProperty'},
254
299
  },
255
300
  '/session/:sessionId/orientation': {
256
301
  GET: {command: 'getOrientation'},
257
- POST: {command: 'setOrientation', payloadParams: {required: ['orientation']}}
302
+ POST: {
303
+ command: 'setOrientation',
304
+ payloadParams: {required: ['orientation']},
305
+ },
258
306
  },
259
307
  '/session/:sessionId/rotation': {
260
308
  GET: {command: 'getRotation'},
261
- POST: {command: 'setRotation', payloadParams: {required: ['x', 'y', 'z']}}
309
+ POST: {command: 'setRotation', payloadParams: {required: ['x', 'y', 'z']}},
262
310
  },
263
311
  '/session/:sessionId/moveto': {
264
- POST: {command: 'moveTo', payloadParams: {optional: ['element', 'xoffset', 'yoffset']}}
312
+ POST: {
313
+ command: 'moveTo',
314
+ payloadParams: {optional: ['element', 'xoffset', 'yoffset']},
315
+ },
265
316
  },
266
317
  '/session/:sessionId/click': {
267
- POST: {command: 'clickCurrent', payloadParams: {optional: ['button']}}
318
+ POST: {command: 'clickCurrent', payloadParams: {optional: ['button']}},
268
319
  },
269
320
  '/session/:sessionId/buttondown': {
270
- POST: {command: 'buttonDown', payloadParams: {optional: ['button']}}
321
+ POST: {command: 'buttonDown', payloadParams: {optional: ['button']}},
271
322
  },
272
323
  '/session/:sessionId/buttonup': {
273
- POST: {command: 'buttonUp', payloadParams: {optional: ['button']}}
324
+ POST: {command: 'buttonUp', payloadParams: {optional: ['button']}},
274
325
  },
275
326
  '/session/:sessionId/doubleclick': {
276
- POST: {command: 'doubleClick'}
327
+ POST: {command: 'doubleClick'},
277
328
  },
278
329
  '/session/:sessionId/touch/click': {
279
- POST: {command: 'click', payloadParams: {required: ['element']}}
330
+ POST: {command: 'click', payloadParams: {required: ['element']}},
280
331
  },
281
332
  '/session/:sessionId/touch/down': {
282
- POST: {command: 'touchDown', payloadParams: {required: ['x', 'y']}}
333
+ POST: {command: 'touchDown', payloadParams: {required: ['x', 'y']}},
283
334
  },
284
335
  '/session/:sessionId/touch/up': {
285
- POST: {command: 'touchUp', payloadParams: {required: ['x', 'y']}}
336
+ POST: {command: 'touchUp', payloadParams: {required: ['x', 'y']}},
286
337
  },
287
338
  '/session/:sessionId/touch/move': {
288
- POST: {command: 'touchMove', payloadParams: {required: ['x', 'y']}}
339
+ POST: {command: 'touchMove', payloadParams: {required: ['x', 'y']}},
289
340
  },
290
341
  '/session/:sessionId/touch/scroll': {
291
- POST: {}
342
+ POST: {},
292
343
  },
293
344
  '/session/:sessionId/touch/doubleclick': {
294
- POST: {}
345
+ POST: {},
295
346
  },
296
347
  '/session/:sessionId/actions': {
297
348
  POST: {command: 'performActions', payloadParams: {required: ['actions']}},
298
- DELETE: {command: 'releaseActions'}
349
+ DELETE: {command: 'releaseActions'},
299
350
  },
300
351
  '/session/:sessionId/touch/longclick': {
301
- POST: {command: 'touchLongClick', payloadParams: {required: ['elements']}}
352
+ POST: {command: 'touchLongClick', payloadParams: {required: ['elements']}},
302
353
  },
303
354
  '/session/:sessionId/touch/flick': {
304
- POST: {command: 'flick', payloadParams: {optional: ['element', 'xspeed', 'yspeed', 'xoffset', 'yoffset', 'speed']}}
355
+ POST: {
356
+ command: 'flick',
357
+ payloadParams: {
358
+ optional: ['element', 'xspeed', 'yspeed', 'xoffset', 'yoffset', 'speed'],
359
+ },
360
+ },
305
361
  },
306
362
  '/session/:sessionId/location': {
307
363
  GET: {command: 'getGeoLocation'},
308
- POST: {command: 'setGeoLocation', payloadParams: {required: ['location']}}
364
+ POST: {command: 'setGeoLocation', payloadParams: {required: ['location']}},
309
365
  },
310
366
  '/session/:sessionId/local_storage': {
311
367
  GET: {},
312
368
  POST: {},
313
- DELETE: {}
369
+ DELETE: {},
314
370
  },
315
371
  '/session/:sessionId/local_storage/key/:key': {
316
372
  GET: {},
317
- DELETE: {}
373
+ DELETE: {},
318
374
  },
319
375
  '/session/:sessionId/local_storage/size': {
320
- GET: {}
376
+ GET: {},
321
377
  },
322
378
  '/session/:sessionId/session_storage': {
323
379
  GET: {},
324
380
  POST: {},
325
- DELETE: {}
381
+ DELETE: {},
326
382
  },
327
383
  '/session/:sessionId/session_storage/key/:key': {
328
384
  GET: {},
329
- DELETE: {}
385
+ DELETE: {},
330
386
  },
331
387
  '/session/:sessionId/session_storage/size': {
332
- GET: {}
388
+ GET: {},
333
389
  },
334
390
  // Selenium 4 clients
335
391
  '/session/:sessionId/se/log': {
336
- POST: {command: 'getLog', payloadParams: {required: ['type']}}
392
+ POST: {command: 'getLog', payloadParams: {required: ['type']}},
337
393
  },
338
394
  // Selenium 4 clients
339
395
  '/session/:sessionId/se/log/types': {
340
- GET: {command: 'getLogTypes'}
396
+ GET: {command: 'getLogTypes'},
341
397
  },
342
398
  // mjsonwire, appium clients
343
399
  '/session/:sessionId/log': {
344
- POST: {command: 'getLog', payloadParams: {required: ['type']}}
400
+ POST: {command: 'getLog', payloadParams: {required: ['type']}},
345
401
  },
346
402
  // mjsonwire, appium clients
347
403
  '/session/:sessionId/log/types': {
348
- GET: {command: 'getLogTypes'}
404
+ GET: {command: 'getLogTypes'},
349
405
  },
350
406
  '/session/:sessionId/application_cache/status': {
351
- GET: {}
407
+ GET: {},
352
408
  },
353
409
 
354
410
  //
@@ -356,107 +412,157 @@ const METHOD_MAP = {
356
412
  //
357
413
  '/session/:sessionId/context': {
358
414
  GET: {command: 'getCurrentContext'},
359
- POST: {command: 'setContext', payloadParams: {required: ['name']}}
415
+ POST: {command: 'setContext', payloadParams: {required: ['name']}},
360
416
  },
361
417
  '/session/:sessionId/contexts': {
362
- GET: {command: 'getContexts'}
418
+ GET: {command: 'getContexts'},
363
419
  },
364
420
  '/session/:sessionId/element/:elementId/pageIndex': {
365
- GET: {command: 'getPageIndex'}
421
+ GET: {command: 'getPageIndex'},
366
422
  },
367
423
  '/session/:sessionId/network_connection': {
368
424
  GET: {command: 'getNetworkConnection'},
369
- POST: {command: 'setNetworkConnection', payloadParams: {unwrap: 'parameters', required: ['type']}}
425
+ POST: {
426
+ command: 'setNetworkConnection',
427
+ payloadParams: {unwrap: 'parameters', required: ['type']},
428
+ },
370
429
  },
371
430
  '/session/:sessionId/touch/perform': {
372
- POST: {command: 'performTouch', payloadParams: {wrap: 'actions', required: ['actions']}}
431
+ POST: {
432
+ command: 'performTouch',
433
+ payloadParams: {wrap: 'actions', required: ['actions']},
434
+ },
373
435
  },
374
436
  '/session/:sessionId/touch/multi/perform': {
375
- POST: {command: 'performMultiAction', payloadParams: {required: ['actions'], optional: ['elementId']}}
437
+ POST: {
438
+ command: 'performMultiAction',
439
+ payloadParams: {required: ['actions'], optional: ['elementId']},
440
+ },
376
441
  },
377
442
  '/session/:sessionId/receive_async_response': {
378
- POST: {command: 'receiveAsyncResponse', payloadParams: {required: ['status', 'value']}}
443
+ POST: {
444
+ command: 'receiveAsyncResponse',
445
+ payloadParams: {required: ['status', 'value']},
446
+ },
379
447
  },
380
448
  '/session/:sessionId/appium/device/shake': {
381
- POST: {command: 'mobileShake'}
449
+ POST: {command: 'mobileShake'},
382
450
  },
383
451
  '/session/:sessionId/appium/device/system_time': {
384
452
  GET: {command: 'getDeviceTime', payloadParams: {optional: ['format']}},
385
- POST: {command: 'getDeviceTime', payloadParams: {optional: ['format']}}
453
+ POST: {command: 'getDeviceTime', payloadParams: {optional: ['format']}},
386
454
  },
387
455
  '/session/:sessionId/appium/device/lock': {
388
- POST: {command: 'lock', payloadParams: {optional: ['seconds']}}
456
+ POST: {command: 'lock', payloadParams: {optional: ['seconds']}},
389
457
  },
390
458
  '/session/:sessionId/appium/device/unlock': {
391
- POST: {command: 'unlock'}
459
+ POST: {command: 'unlock'},
392
460
  },
393
461
  '/session/:sessionId/appium/device/is_locked': {
394
- POST: {command: 'isLocked'}
462
+ POST: {command: 'isLocked'},
395
463
  },
396
464
  '/session/:sessionId/appium/start_recording_screen': {
397
- POST: {command: 'startRecordingScreen', payloadParams: {optional: ['options']}}
465
+ POST: {
466
+ command: 'startRecordingScreen',
467
+ payloadParams: {optional: ['options']},
468
+ },
398
469
  },
399
470
  '/session/:sessionId/appium/stop_recording_screen': {
400
- POST: {command: 'stopRecordingScreen', payloadParams: {optional: ['options']}}
471
+ POST: {
472
+ command: 'stopRecordingScreen',
473
+ payloadParams: {optional: ['options']},
474
+ },
401
475
  },
402
476
  '/session/:sessionId/appium/performanceData/types': {
403
- POST: {command: 'getPerformanceDataTypes'}
477
+ POST: {command: 'getPerformanceDataTypes'},
404
478
  },
405
479
  '/session/:sessionId/appium/getPerformanceData': {
406
- POST: {command: 'getPerformanceData', payloadParams: {required: ['packageName', 'dataType'], optional: ['dataReadTimeout']}}
480
+ POST: {
481
+ command: 'getPerformanceData',
482
+ payloadParams: {
483
+ required: ['packageName', 'dataType'],
484
+ optional: ['dataReadTimeout'],
485
+ },
486
+ },
407
487
  },
408
488
  '/session/:sessionId/appium/device/press_keycode': {
409
- POST: {command: 'pressKeyCode', payloadParams: {required: ['keycode'], optional: ['metastate', 'flags']}}
489
+ POST: {
490
+ command: 'pressKeyCode',
491
+ payloadParams: {required: ['keycode'], optional: ['metastate', 'flags']},
492
+ },
410
493
  },
411
494
  '/session/:sessionId/appium/device/long_press_keycode': {
412
- POST: {command: 'longPressKeyCode', payloadParams: {required: ['keycode'], optional: ['metastate', 'flags']}}
495
+ POST: {
496
+ command: 'longPressKeyCode',
497
+ payloadParams: {required: ['keycode'], optional: ['metastate', 'flags']},
498
+ },
413
499
  },
414
500
  '/session/:sessionId/appium/device/finger_print': {
415
- POST: {command: 'fingerprint', payloadParams: {required: ['fingerprintId']}}
501
+ POST: {
502
+ command: 'fingerprint',
503
+ payloadParams: {required: ['fingerprintId']},
504
+ },
416
505
  },
417
506
  '/session/:sessionId/appium/device/send_sms': {
418
- POST: {command: 'sendSMS', payloadParams: {required: ['phoneNumber', 'message']}}
507
+ POST: {
508
+ command: 'sendSMS',
509
+ payloadParams: {required: ['phoneNumber', 'message']},
510
+ },
419
511
  },
420
512
  '/session/:sessionId/appium/device/gsm_call': {
421
- POST: {command: 'gsmCall', payloadParams: {required: ['phoneNumber', 'action']}}
513
+ POST: {
514
+ command: 'gsmCall',
515
+ payloadParams: {required: ['phoneNumber', 'action']},
516
+ },
422
517
  },
423
518
  '/session/:sessionId/appium/device/gsm_signal': {
424
519
  POST: {
425
520
  command: 'gsmSignal',
426
521
  payloadParams: {
427
- validate: (jsonObj) => (!util.hasValue(jsonObj.signalStrength) && !util.hasValue(jsonObj.signalStrengh)) &&
428
- 'we require one of "signalStrength" or "signalStrengh" params',
522
+ validate: (jsonObj) =>
523
+ !util.hasValue(jsonObj.signalStrength) &&
524
+ !util.hasValue(jsonObj.signalStrengh) &&
525
+ 'we require one of "signalStrength" or "signalStrengh" params',
429
526
  optional: ['signalStrength', 'signalStrengh'],
430
527
  // backward-compatible. sonObj.signalStrength can be 0
431
- makeArgs: (jsonObj) => [util.hasValue(jsonObj.signalStrength) ? jsonObj.signalStrength : jsonObj.signalStrengh]
432
- }
433
- }
528
+ makeArgs: (jsonObj) => [
529
+ util.hasValue(jsonObj.signalStrength) ? jsonObj.signalStrength : jsonObj.signalStrengh,
530
+ ],
531
+ },
532
+ },
434
533
  },
435
534
  '/session/:sessionId/appium/device/gsm_voice': {
436
- POST: {command: 'gsmVoice', payloadParams: {required: ['state']}}
535
+ POST: {command: 'gsmVoice', payloadParams: {required: ['state']}},
437
536
  },
438
537
  '/session/:sessionId/appium/device/power_capacity': {
439
- POST: {command: 'powerCapacity', payloadParams: {required: ['percent']}}
538
+ POST: {command: 'powerCapacity', payloadParams: {required: ['percent']}},
440
539
  },
441
540
  '/session/:sessionId/appium/device/power_ac': {
442
- POST: {command: 'powerAC', payloadParams: {required: ['state']}}
541
+ POST: {command: 'powerAC', payloadParams: {required: ['state']}},
443
542
  },
444
543
  '/session/:sessionId/appium/device/network_speed': {
445
- POST: {command: 'networkSpeed', payloadParams: {required: ['netspeed']}}
544
+ POST: {command: 'networkSpeed', payloadParams: {required: ['netspeed']}},
446
545
  },
447
546
  '/session/:sessionId/appium/device/keyevent': {
448
- POST: {command: 'keyevent', payloadParams: {required: ['keycode'], optional: ['metastate']}}
547
+ POST: {
548
+ command: 'keyevent',
549
+ payloadParams: {required: ['keycode'], optional: ['metastate']},
550
+ },
449
551
  },
450
552
  '/session/:sessionId/appium/device/rotate': {
451
- POST: {command: 'mobileRotation', payloadParams: {
452
- required: ['x', 'y', 'radius', 'rotation', 'touchCount', 'duration'],
453
- optional: ['element'] }}
553
+ POST: {
554
+ command: 'mobileRotation',
555
+ payloadParams: {
556
+ required: ['x', 'y', 'radius', 'rotation', 'touchCount', 'duration'],
557
+ optional: ['element'],
558
+ },
559
+ },
454
560
  },
455
561
  '/session/:sessionId/appium/device/current_activity': {
456
- GET: {command: 'getCurrentActivity'}
562
+ GET: {command: 'getCurrentActivity'},
457
563
  },
458
564
  '/session/:sessionId/appium/device/current_package': {
459
- GET: {command: 'getCurrentPackage'}
565
+ GET: {command: 'getCurrentPackage'},
460
566
  },
461
567
  //region Applications Management
462
568
  '/session/:sessionId/appium/device/install_app': {
@@ -464,164 +570,199 @@ const METHOD_MAP = {
464
570
  command: 'installApp',
465
571
  payloadParams: {
466
572
  required: ['appPath'],
467
- optional: ['options']
468
- }
469
- }
573
+ optional: ['options'],
574
+ },
575
+ },
470
576
  },
471
577
  '/session/:sessionId/appium/device/activate_app': {
472
578
  POST: {
473
579
  command: 'activateApp',
474
580
  payloadParams: {
475
581
  required: [['appId'], ['bundleId']],
476
- optional: ['options']
477
- }
478
- }
582
+ optional: ['options'],
583
+ },
584
+ },
479
585
  },
480
586
  '/session/:sessionId/appium/device/remove_app': {
481
587
  POST: {
482
588
  command: 'removeApp',
483
589
  payloadParams: {
484
590
  required: [['appId'], ['bundleId']],
485
- optional: ['options']
486
- }
487
- }
591
+ optional: ['options'],
592
+ },
593
+ },
488
594
  },
489
595
  '/session/:sessionId/appium/device/terminate_app': {
490
596
  POST: {
491
597
  command: 'terminateApp',
492
598
  payloadParams: {
493
599
  required: [['appId'], ['bundleId']],
494
- optional: ['options']
495
- }
496
- }
600
+ optional: ['options'],
601
+ },
602
+ },
497
603
  },
498
604
  '/session/:sessionId/appium/device/app_installed': {
499
605
  POST: {
500
606
  command: 'isAppInstalled',
501
607
  payloadParams: {
502
- required: [['appId'], ['bundleId']]
503
- }
504
- }
608
+ required: [['appId'], ['bundleId']],
609
+ },
610
+ },
505
611
  },
506
612
  '/session/:sessionId/appium/device/app_state': {
507
613
  GET: {
508
614
  command: 'queryAppState',
509
615
  payloadParams: {
510
- required: [['appId'], ['bundleId']]
511
- }
616
+ required: [['appId'], ['bundleId']],
617
+ },
512
618
  },
513
619
  POST: {
514
620
  command: 'queryAppState',
515
621
  payloadParams: {
516
- required: [['appId'], ['bundleId']]
517
- }
518
- }
622
+ required: [['appId'], ['bundleId']],
623
+ },
624
+ },
519
625
  },
520
626
  //endregion
521
627
  '/session/:sessionId/appium/device/hide_keyboard': {
522
- POST: {command: 'hideKeyboard', payloadParams: {optional: ['strategy', 'key', 'keyCode', 'keyName']}}
628
+ POST: {
629
+ command: 'hideKeyboard',
630
+ payloadParams: {optional: ['strategy', 'key', 'keyCode', 'keyName']},
631
+ },
523
632
  },
524
633
  '/session/:sessionId/appium/device/is_keyboard_shown': {
525
- GET: {command: 'isKeyboardShown'}
634
+ GET: {command: 'isKeyboardShown'},
526
635
  },
527
636
  '/session/:sessionId/appium/device/push_file': {
528
- POST: {command: 'pushFile', payloadParams: {required: ['path', 'data']}}
637
+ POST: {command: 'pushFile', payloadParams: {required: ['path', 'data']}},
529
638
  },
530
639
  '/session/:sessionId/appium/device/pull_file': {
531
- POST: {command: 'pullFile', payloadParams: {required: ['path']}}
640
+ POST: {command: 'pullFile', payloadParams: {required: ['path']}},
532
641
  },
533
642
  '/session/:sessionId/appium/device/pull_folder': {
534
- POST: {command: 'pullFolder', payloadParams: {required: ['path']}}
643
+ POST: {command: 'pullFolder', payloadParams: {required: ['path']}},
535
644
  },
536
645
  '/session/:sessionId/appium/device/toggle_airplane_mode': {
537
- POST: {command: 'toggleFlightMode'}
646
+ POST: {command: 'toggleFlightMode'},
538
647
  },
539
648
  '/session/:sessionId/appium/device/toggle_data': {
540
- POST: {command: 'toggleData'}
649
+ POST: {command: 'toggleData'},
541
650
  },
542
651
  '/session/:sessionId/appium/device/toggle_wifi': {
543
- POST: {command: 'toggleWiFi'}
652
+ POST: {command: 'toggleWiFi'},
544
653
  },
545
654
  '/session/:sessionId/appium/device/toggle_location_services': {
546
- POST: {command: 'toggleLocationServices'}
655
+ POST: {command: 'toggleLocationServices'},
547
656
  },
548
657
  '/session/:sessionId/appium/device/open_notifications': {
549
- POST: {command: 'openNotifications'}
658
+ POST: {command: 'openNotifications'},
550
659
  },
551
660
  '/session/:sessionId/appium/device/start_activity': {
552
661
  POST: {
553
662
  command: 'startActivity',
554
663
  payloadParams: {
555
664
  required: ['appPackage', 'appActivity'],
556
- optional: ['appWaitPackage', 'appWaitActivity', 'intentAction',
557
- 'intentCategory', 'intentFlags', 'optionalIntentArguments', 'dontStopAppOnReset']
558
- }
559
- }
665
+ optional: [
666
+ 'appWaitPackage',
667
+ 'appWaitActivity',
668
+ 'intentAction',
669
+ 'intentCategory',
670
+ 'intentFlags',
671
+ 'optionalIntentArguments',
672
+ 'dontStopAppOnReset',
673
+ ],
674
+ },
675
+ },
560
676
  },
561
677
  '/session/:sessionId/appium/device/system_bars': {
562
- GET: {command: 'getSystemBars'}
678
+ GET: {command: 'getSystemBars'},
563
679
  },
564
680
  '/session/:sessionId/appium/device/display_density': {
565
- GET: {command: 'getDisplayDensity'}
681
+ GET: {command: 'getDisplayDensity'},
566
682
  },
567
683
  '/session/:sessionId/appium/simulator/touch_id': {
568
- POST: {command: 'touchId', payloadParams: {required: ['match']}}
684
+ POST: {command: 'touchId', payloadParams: {required: ['match']}},
569
685
  },
570
686
  '/session/:sessionId/appium/simulator/toggle_touch_id_enrollment': {
571
- POST: {command: 'toggleEnrollTouchId', payloadParams: {optional: ['enabled']}}
687
+ POST: {
688
+ command: 'toggleEnrollTouchId',
689
+ payloadParams: {optional: ['enabled']},
690
+ },
572
691
  },
573
692
  '/session/:sessionId/appium/app/launch': {
574
- POST: {command: 'launchApp'}
693
+ POST: {command: 'launchApp'},
575
694
  },
576
695
  '/session/:sessionId/appium/app/close': {
577
- POST: {command: 'closeApp'}
696
+ POST: {command: 'closeApp'},
578
697
  },
579
698
  '/session/:sessionId/appium/app/reset': {
580
- POST: {command: 'reset'}
699
+ POST: {command: 'reset'},
581
700
  },
582
701
  '/session/:sessionId/appium/app/background': {
583
- POST: {command: 'background', payloadParams: {required: ['seconds']}}
702
+ POST: {command: 'background', payloadParams: {required: ['seconds']}},
584
703
  },
585
704
  '/session/:sessionId/appium/app/end_test_coverage': {
586
- POST: {command: 'endCoverage', payloadParams: {required: ['intent', 'path']}}
705
+ POST: {
706
+ command: 'endCoverage',
707
+ payloadParams: {required: ['intent', 'path']},
708
+ },
587
709
  },
588
710
  '/session/:sessionId/appium/app/strings': {
589
- POST: {command: 'getStrings', payloadParams: {optional: ['language', 'stringFile']}}
711
+ POST: {
712
+ command: 'getStrings',
713
+ payloadParams: {optional: ['language', 'stringFile']},
714
+ },
590
715
  },
591
716
  '/session/:sessionId/appium/element/:elementId/value': {
592
- POST: {command: 'setValueImmediate', payloadParams: {
593
- validate: (jsonObj) => (!util.hasValue(jsonObj.value) && !util.hasValue(jsonObj.text)) &&
717
+ POST: {
718
+ command: 'setValueImmediate',
719
+ payloadParams: {
720
+ validate: (jsonObj) =>
721
+ !util.hasValue(jsonObj.value) &&
722
+ !util.hasValue(jsonObj.text) &&
594
723
  'we require one of "text" or "value" params',
595
- optional: ['value', 'text'],
596
- // We want to either a value (old JSONWP) or a text (new W3C) parameter,
597
- // but only send one of them to the command (not both).
598
- // Prefer 'value' since it's more backward-compatible.
599
- makeArgs: (jsonObj) => [jsonObj.value || jsonObj.text],
600
- }}
724
+ optional: ['value', 'text'],
725
+ // We want to either a value (old JSONWP) or a text (new W3C) parameter,
726
+ // but only send one of them to the command (not both).
727
+ // Prefer 'value' since it's more backward-compatible.
728
+ makeArgs: (jsonObj) => [jsonObj.value || jsonObj.text],
729
+ },
730
+ },
601
731
  },
602
732
  '/session/:sessionId/appium/element/:elementId/replace_value': {
603
- POST: {command: 'replaceValue', payloadParams: {
604
- validate: (jsonObj) => (!util.hasValue(jsonObj.value) && !util.hasValue(jsonObj.text)) &&
733
+ POST: {
734
+ command: 'replaceValue',
735
+ payloadParams: {
736
+ validate: (jsonObj) =>
737
+ !util.hasValue(jsonObj.value) &&
738
+ !util.hasValue(jsonObj.text) &&
605
739
  'we require one of "text" or "value" params',
606
- optional: ['value', 'text'],
607
- // We want to either a value (old JSONWP) or a text (new W3C) parameter,
608
- // but only send one of them to the command (not both).
609
- // Prefer 'value' since it's more backward-compatible.
610
- makeArgs: (jsonObj) => [jsonObj.value ?? jsonObj.text ?? ''],
611
- }}
740
+ optional: ['value', 'text'],
741
+ // We want to either a value (old JSONWP) or a text (new W3C) parameter,
742
+ // but only send one of them to the command (not both).
743
+ // Prefer 'value' since it's more backward-compatible.
744
+ makeArgs: (jsonObj) => [jsonObj.value ?? jsonObj.text ?? ''],
745
+ },
746
+ },
612
747
  },
613
748
  '/session/:sessionId/appium/settings': {
614
749
  POST: {command: 'updateSettings', payloadParams: {required: ['settings']}},
615
- GET: {command: 'getSettings'}
750
+ GET: {command: 'getSettings'},
616
751
  },
617
752
  '/session/:sessionId/appium/receive_async_response': {
618
- POST: {command: 'receiveAsyncResponse', payloadParams: {required: ['response']}}
753
+ POST: {
754
+ command: 'receiveAsyncResponse',
755
+ payloadParams: {required: ['response']},
756
+ },
619
757
  },
620
758
  '/session/:sessionId/appium/events': {
621
- POST: {command: 'getLogEvents', payloadParams: {optional: ['type']}}
759
+ POST: {command: 'getLogEvents', payloadParams: {optional: ['type']}},
622
760
  },
623
761
  '/session/:sessionId/appium/log_event': {
624
- POST: {command: 'logCustomEvent', payloadParams: {required: ['vendor', 'event']}}
762
+ POST: {
763
+ command: 'logCustomEvent',
764
+ payloadParams: {required: ['vendor', 'event']},
765
+ },
625
766
  },
626
767
 
627
768
  /*
@@ -636,15 +777,15 @@ const METHOD_MAP = {
636
777
  POST: {
637
778
  command: 'setAlertText',
638
779
  payloadParams: SET_ALERT_TEXT_PAYLOAD_PARAMS,
639
- }
780
+ },
640
781
  },
641
782
  // MJSONWP
642
783
  '/session/:sessionId/accept_alert': {
643
- POST: {command: 'postAcceptAlert'}
784
+ POST: {command: 'postAcceptAlert'},
644
785
  },
645
786
  // MJSONWP
646
787
  '/session/:sessionId/dismiss_alert': {
647
- POST: {command: 'postDismissAlert'}
788
+ POST: {command: 'postDismissAlert'},
648
789
  },
649
790
  // https://w3c.github.io/webdriver/webdriver-spec.html#user-prompts
650
791
  '/session/:sessionId/alert/text': {
@@ -652,77 +793,78 @@ const METHOD_MAP = {
652
793
  POST: {
653
794
  command: 'setAlertText',
654
795
  payloadParams: SET_ALERT_TEXT_PAYLOAD_PARAMS,
655
- }
796
+ },
656
797
  },
657
798
  '/session/:sessionId/alert/accept': {
658
- POST: {command: 'postAcceptAlert'}
799
+ POST: {command: 'postAcceptAlert'},
659
800
  },
660
801
  '/session/:sessionId/alert/dismiss': {
661
- POST: {command: 'postDismissAlert'}
802
+ POST: {command: 'postDismissAlert'},
662
803
  },
663
804
  // https://w3c.github.io/webdriver/webdriver-spec.html#get-element-rect
664
805
  '/session/:sessionId/element/:elementId/rect': {
665
- GET: {command: 'getElementRect'}
806
+ GET: {command: 'getElementRect'},
666
807
  },
667
808
  '/session/:sessionId/execute/sync': {
668
- POST: {command: 'execute', payloadParams: {required: ['script', 'args']}}
809
+ POST: {command: 'execute', payloadParams: {required: ['script', 'args']}},
669
810
  },
670
811
  '/session/:sessionId/execute/async': {
671
- POST: {command: 'executeAsync', payloadParams: {required: ['script', 'args']}}
812
+ POST: {
813
+ command: 'executeAsync',
814
+ payloadParams: {required: ['script', 'args']},
815
+ },
672
816
  },
673
817
  // Pre-W3C endpoint for element screenshot
674
818
  '/session/:sessionId/screenshot/:elementId': {
675
- GET: {command: 'getElementScreenshot'}
819
+ GET: {command: 'getElementScreenshot'},
676
820
  },
677
821
  '/session/:sessionId/element/:elementId/screenshot': {
678
- GET: {command: 'getElementScreenshot'}
822
+ GET: {command: 'getElementScreenshot'},
679
823
  },
680
824
  '/session/:sessionId/window/rect': {
681
825
  GET: {command: 'getWindowRect'},
682
- POST: {command: 'setWindowRect', payloadParams: {required: ['x', 'y', 'width', 'height']}},
826
+ POST: {
827
+ command: 'setWindowRect',
828
+ payloadParams: {required: ['x', 'y', 'width', 'height']},
829
+ },
683
830
  },
684
831
  '/session/:sessionId/window/maximize': {
685
- POST: {command: 'maximizeWindow'}
832
+ POST: {command: 'maximizeWindow'},
686
833
  },
687
834
  '/session/:sessionId/window/minimize': {
688
- POST: {command: 'minimizeWindow'}
835
+ POST: {command: 'minimizeWindow'},
689
836
  },
690
837
  '/session/:sessionId/window/fullscreen': {
691
- POST: {command: 'fullScreenWindow'}
838
+ POST: {command: 'fullScreenWindow'},
692
839
  },
693
840
  '/session/:sessionId/window/new': {
694
- POST: {command: 'createNewWindow', payloadParams: {optional: ['type']}}
841
+ POST: {command: 'createNewWindow', payloadParams: {optional: ['type']}},
695
842
  },
696
843
  '/session/:sessionId/element/:elementId/property/:name': {
697
- GET: {command: 'getProperty'}
844
+ GET: {command: 'getProperty'},
698
845
  },
699
846
  '/session/:sessionId/appium/device/set_clipboard': {
700
847
  POST: {
701
848
  command: 'setClipboard',
702
849
  payloadParams: {
703
850
  required: ['content'],
704
- optional: [
705
- 'contentType',
706
- 'label',
707
- ]
851
+ optional: ['contentType', 'label'],
708
852
  },
709
- }
853
+ },
710
854
  },
711
855
  '/session/:sessionId/appium/device/get_clipboard': {
712
856
  POST: {
713
857
  command: 'getClipboard',
714
858
  payloadParams: {
715
- optional: [
716
- 'contentType',
717
- ]
859
+ optional: ['contentType'],
718
860
  },
719
- }
861
+ },
720
862
  },
721
863
 
722
864
  // chromium devtools
723
865
  // https://chromium.googlesource.com/chromium/src/+/master/chrome/test/chromedriver/server/http_handler.cc
724
866
  '/session/:sessionId/:vendor/cdp/execute': {
725
- POST: {command: 'executeCdp', payloadParams: {required: ['cmd', 'params']}}
867
+ POST: {command: 'executeCdp', payloadParams: {required: ['cmd', 'params']}},
726
868
  },
727
869
 
728
870
  //region Webauthn
@@ -734,14 +876,14 @@ const METHOD_MAP = {
734
876
  payloadParams: {
735
877
  required: ['protocol', 'transport'],
736
878
  optional: ['hasResidentKey', 'hasUserVerification', 'isUserConsenting', 'isUserVerified'],
737
- }
738
- }
879
+ },
880
+ },
739
881
  },
740
882
 
741
883
  '/session/:sessionId/webauthn/authenticator/:authenticatorId': {
742
884
  DELETE: {
743
- command: 'removeVirtualAuthenticator'
744
- }
885
+ command: 'removeVirtualAuthenticator',
886
+ },
745
887
  },
746
888
 
747
889
  '/session/:sessionId/webauthn/authenticator/:authenticatorId/credential': {
@@ -750,8 +892,8 @@ const METHOD_MAP = {
750
892
  payloadParams: {
751
893
  required: ['credentialId', 'isResidentCredential', 'rpId', 'privateKey'],
752
894
  optional: ['userHandle', 'signCount'],
753
- }
754
- }
895
+ },
896
+ },
755
897
  },
756
898
 
757
899
  '/session/:sessionId/webauthn/authenticator/:authenticatorId/credentials': {
@@ -760,20 +902,19 @@ const METHOD_MAP = {
760
902
  },
761
903
 
762
904
  '/session/:sessionId/webauthn/authenticator/:authenticatorId/credentials/:credentialId': {
763
- DELETE: {command: 'removeAuthCredential'}
905
+ DELETE: {command: 'removeAuthCredential'},
764
906
  },
765
907
 
766
908
  '/session/:sessionId/webauthn/authenticator/:authenticatorId/uv': {
767
909
  POST: {
768
910
  command: 'setUserAuthVerified',
769
911
  payloadParams: {
770
- required: ['isUserVerified']
771
- }
772
- }
912
+ required: ['isUserVerified'],
913
+ },
914
+ },
773
915
  },
774
916
 
775
917
  //endregion
776
-
777
918
  };
778
919
 
779
920
  // driver command names
@@ -790,7 +931,7 @@ const RE_ESCAPE = /[-[\]{}()+?.,\\^$|#\s]/g;
790
931
  const RE_PARAM = /([:*])(\w+)/g;
791
932
 
792
933
  class Route {
793
- constructor (route) {
934
+ constructor(route) {
794
935
  this.paramNames = [];
795
936
 
796
937
  let reStr = route.replace(RE_ESCAPE, '\\$&');
@@ -801,7 +942,7 @@ class Route {
801
942
  this.routeRegexp = new RegExp(`^${reStr}$`);
802
943
  }
803
944
 
804
- parse (url) {
945
+ parse(url) {
805
946
  //if (url.indexOf('timeouts') !== -1 && this.routeRegexp.toString().indexOf('timeouts') !== -1) {
806
947
  //debugger;
807
948
  //}
@@ -817,22 +958,33 @@ class Route {
817
958
  }
818
959
  }
819
960
 
820
- function routeToCommandName (endpoint, method, basePath = DEFAULT_BASE_PATH) {
961
+ /**
962
+ *
963
+ * @param {string} endpoint
964
+ * @param {import('@appium/types').HTTPMethod} method
965
+ * @param {string} [basePath]
966
+ * @returns {string|undefined}
967
+ */
968
+ function routeToCommandName(endpoint, method, basePath = DEFAULT_BASE_PATH) {
821
969
  let dstRoute = null;
822
970
 
823
971
  // remove any query string
972
+ // TODO: would this be better handled as a `URL` object?
824
973
  if (endpoint.includes('?')) {
825
974
  endpoint = endpoint.slice(0, endpoint.indexOf('?'));
826
975
  }
827
976
 
828
- const actualEndpoint = endpoint === '/' ? '' :
829
- (_.startsWith(endpoint, '/') ? endpoint : `/${endpoint}`);
977
+ const actualEndpoint =
978
+ endpoint === '/' ? '' : _.startsWith(endpoint, '/') ? endpoint : `/${endpoint}`;
830
979
 
831
980
  for (let currentRoute of _.keys(METHOD_MAP)) {
832
981
  const route = new Route(`${basePath}${currentRoute}`);
833
982
  // we don't care about the actual session id for matching
834
- if (route.parse(`${basePath}/session/ignored-session-id${actualEndpoint}`) ||
835
- route.parse(`${basePath}${actualEndpoint}`) || route.parse(actualEndpoint)) {
983
+ if (
984
+ route.parse(`${basePath}/session/ignored-session-id${actualEndpoint}`) ||
985
+ route.parse(`${basePath}${actualEndpoint}`) ||
986
+ route.parse(actualEndpoint)
987
+ ) {
836
988
  dstRoute = currentRoute;
837
989
  break;
838
990
  }
@@ -840,7 +992,7 @@ function routeToCommandName (endpoint, method, basePath = DEFAULT_BASE_PATH) {
840
992
  if (!dstRoute) return; // eslint-disable-line curly
841
993
 
842
994
  const methods = _.get(METHOD_MAP, dstRoute);
843
- method = _.toUpper(method);
995
+ method = /** @type {Uppercase<typeof method>} */ (_.toUpper(method));
844
996
  if (_.has(methods, method)) {
845
997
  const dstMethod = _.get(methods, method);
846
998
  if (dstMethod.command) {
@@ -852,4 +1004,9 @@ function routeToCommandName (endpoint, method, basePath = DEFAULT_BASE_PATH) {
852
1004
  // driver commands that do not require a session to already exist
853
1005
  const NO_SESSION_ID_COMMANDS = ['createSession', 'getStatus', 'getSessions'];
854
1006
 
855
- export { METHOD_MAP, ALL_COMMANDS, NO_SESSION_ID_COMMANDS, routeToCommandName };
1007
+ export {METHOD_MAP, ALL_COMMANDS, NO_SESSION_ID_COMMANDS, routeToCommandName};
1008
+
1009
+ /**
1010
+ * @typedef {import('@appium/types').Driver} Driver
1011
+ * @typedef {import('@appium/types').MethodMap} MethodMap
1012
+ */