Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
seleniumhq
GitHub Repository: seleniumhq/selenium
Path: blob/trunk/javascript/selenium-webdriver/lib/http.js
4506 views
1
// Licensed to the Software Freedom Conservancy (SFC) under one
2
// or more contributor license agreements. See the NOTICE file
3
// distributed with this work for additional information
4
// regarding copyright ownership. The SFC licenses this file
5
// to you under the Apache License, Version 2.0 (the
6
// "License"); you may not use this file except in compliance
7
// with the License. You may obtain a copy of the License at
8
//
9
// http://www.apache.org/licenses/LICENSE-2.0
10
//
11
// Unless required by applicable law or agreed to in writing,
12
// software distributed under the License is distributed on an
13
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
// KIND, either express or implied. See the License for the
15
// specific language governing permissions and limitations
16
// under the License.
17
18
/**
19
* @fileoverview Defines an environment agnostic {@linkplain cmd.Executor
20
* command executor} that communicates with a remote end using JSON over HTTP.
21
*
22
* Clients should implement the {@link Client} interface, which is used by
23
* the {@link Executor} to send commands to the remote end.
24
*/
25
26
'use strict'
27
28
const path = require('node:path')
29
const cmd = require('./command')
30
const error = require('./error')
31
const logging = require('./logging')
32
const promise = require('./promise')
33
const { Session } = require('./session')
34
const webElement = require('./webelement')
35
const { isObject } = require('./util')
36
37
const log_ = logging.getLogger(`${logging.Type.DRIVER}.http`)
38
39
const getAttribute = requireAtom('get-attribute.js', '//javascript/selenium-webdriver/lib/atoms:get-attribute.js')
40
const isDisplayed = requireAtom('is-displayed.js', '//javascript/selenium-webdriver/lib/atoms:is-displayed.js')
41
const findElements = requireAtom('find-elements.js', '//javascript/selenium-webdriver/lib/atoms:find-elements.js')
42
43
/**
44
* @param {string} module
45
* @param {string} bazelTarget
46
* @return {!Function}
47
*/
48
function requireAtom(module, bazelTarget) {
49
try {
50
return require('./atoms/' + module)
51
} catch (ex) {
52
try {
53
const file = bazelTarget.slice(2).replace(':', '/')
54
log_.log(`../../../bazel-bin/${file}`)
55
return require(path.resolve(`../../../bazel-bin/${file}`))
56
} catch (ex2) {
57
log_.severe(ex2)
58
throw Error(
59
`Failed to import atoms module ${module}. If running in dev mode, you` +
60
` need to run \`bazel build ${bazelTarget}\` from the project` +
61
`root: ${ex}`,
62
)
63
}
64
}
65
}
66
67
/**
68
* Converts a headers map to a HTTP header block string.
69
* @param {!Map<string, string>} headers The map to convert.
70
* @return {string} The headers as a string.
71
*/
72
function headersToString(headers) {
73
const ret = []
74
headers.forEach(function (value, name) {
75
ret.push(`${name.toLowerCase()}: ${value}`)
76
})
77
return ret.join('\n')
78
}
79
80
/**
81
* Represents a HTTP request message. This class is a "partial" request and only
82
* defines the path on the server to send a request to. It is each client's
83
* responsibility to build the full URL for the final request.
84
* @final
85
*/
86
class Request {
87
/**
88
* @param {string} method The HTTP method to use for the request.
89
* @param {string} path The path on the server to send the request to.
90
* @param {Object=} opt_data This request's non-serialized JSON payload data.
91
*/
92
constructor(method, path, opt_data) {
93
this.method = /** string */ method
94
this.path = /** string */ path
95
this.data = /** Object */ opt_data
96
this.headers = /** !Map<string, string> */ new Map([['Accept', 'application/json; charset=utf-8']])
97
}
98
99
/** @override */
100
toString() {
101
let ret = `${this.method} ${this.path} HTTP/1.1\n`
102
ret += headersToString(this.headers) + '\n\n'
103
if (this.data) {
104
ret += JSON.stringify(this.data)
105
}
106
return ret
107
}
108
}
109
110
/**
111
* Represents a HTTP response message.
112
* @final
113
*/
114
class Response {
115
/**
116
* @param {number} status The response code.
117
* @param {!Object<string>} headers The response headers. All header names
118
* will be converted to lowercase strings for consistent lookups.
119
* @param {string} body The response body.
120
*/
121
constructor(status, headers, body) {
122
this.status = /** number */ status
123
this.body = /** string */ body
124
this.headers = /** !Map<string, string>*/ new Map()
125
for (let header in headers) {
126
this.headers.set(header.toLowerCase(), headers[header])
127
}
128
}
129
130
/** @override */
131
toString() {
132
let ret = `HTTP/1.1 ${this.status}\n${headersToString(this.headers)}\n\n`
133
if (this.body) {
134
ret += this.body
135
}
136
return ret
137
}
138
}
139
140
/** @enum {!Function} */
141
const Atom = {
142
GET_ATTRIBUTE: getAttribute,
143
IS_DISPLAYED: isDisplayed,
144
FIND_ELEMENTS: findElements,
145
}
146
147
function post(path) {
148
return resource('POST', path)
149
}
150
151
function del(path) {
152
return resource('DELETE', path)
153
}
154
155
function get(path) {
156
return resource('GET', path)
157
}
158
159
function resource(method, path) {
160
return { method: method, path: path }
161
}
162
163
/** @typedef {{method: string, path: string}} */
164
var CommandSpec
165
166
/** @typedef {function(!cmd.Command): !cmd.Command} */
167
var CommandTransformer
168
169
class InternalTypeError extends TypeError {}
170
171
/**
172
* @param {!cmd.Command} command The initial command.
173
* @param {Atom} atom The name of the atom to execute.
174
* @param params
175
* @return {!Command} The transformed command to execute.
176
*/
177
function toExecuteAtomCommand(command, atom, name, ...params) {
178
if (typeof atom !== 'function') {
179
throw new InternalTypeError('atom is not a function: ' + typeof atom)
180
}
181
182
return new cmd.Command(cmd.Name.EXECUTE_SCRIPT)
183
.setParameter('sessionId', command.getParameter('sessionId'))
184
.setParameter('script', `/* ${name} */return (${atom}).apply(null, arguments)`)
185
.setParameter(
186
'args',
187
params.map((param) => command.getParameter(param)),
188
)
189
}
190
191
/** @const {!Map<string, (CommandSpec|CommandTransformer)>} */
192
const W3C_COMMAND_MAP = new Map([
193
// Session management.
194
[cmd.Name.NEW_SESSION, post('/session')],
195
[cmd.Name.QUIT, del('/session/:sessionId')],
196
197
// Server status.
198
[cmd.Name.GET_SERVER_STATUS, get('/status')],
199
200
// timeouts
201
[cmd.Name.GET_TIMEOUT, get('/session/:sessionId/timeouts')],
202
[cmd.Name.SET_TIMEOUT, post('/session/:sessionId/timeouts')],
203
204
// Navigation.
205
[cmd.Name.GET_CURRENT_URL, get('/session/:sessionId/url')],
206
[cmd.Name.GET, post('/session/:sessionId/url')],
207
[cmd.Name.GO_BACK, post('/session/:sessionId/back')],
208
[cmd.Name.GO_FORWARD, post('/session/:sessionId/forward')],
209
[cmd.Name.REFRESH, post('/session/:sessionId/refresh')],
210
211
// Page inspection.
212
[cmd.Name.GET_PAGE_SOURCE, get('/session/:sessionId/source')],
213
[cmd.Name.GET_TITLE, get('/session/:sessionId/title')],
214
215
// Script execution.
216
[cmd.Name.EXECUTE_SCRIPT, post('/session/:sessionId/execute/sync')],
217
[cmd.Name.EXECUTE_ASYNC_SCRIPT, post('/session/:sessionId/execute/async')],
218
219
// Frame selection.
220
[cmd.Name.SWITCH_TO_FRAME, post('/session/:sessionId/frame')],
221
[cmd.Name.SWITCH_TO_FRAME_PARENT, post('/session/:sessionId/frame/parent')],
222
223
// Window management.
224
[cmd.Name.GET_CURRENT_WINDOW_HANDLE, get('/session/:sessionId/window')],
225
[cmd.Name.CLOSE, del('/session/:sessionId/window')],
226
[cmd.Name.SWITCH_TO_WINDOW, post('/session/:sessionId/window')],
227
[cmd.Name.SWITCH_TO_NEW_WINDOW, post('/session/:sessionId/window/new')],
228
[cmd.Name.GET_WINDOW_HANDLES, get('/session/:sessionId/window/handles')],
229
[cmd.Name.GET_WINDOW_RECT, get('/session/:sessionId/window/rect')],
230
[cmd.Name.SET_WINDOW_RECT, post('/session/:sessionId/window/rect')],
231
[cmd.Name.MAXIMIZE_WINDOW, post('/session/:sessionId/window/maximize')],
232
[cmd.Name.MINIMIZE_WINDOW, post('/session/:sessionId/window/minimize')],
233
[cmd.Name.FULLSCREEN_WINDOW, post('/session/:sessionId/window/fullscreen')],
234
235
// Actions.
236
[cmd.Name.ACTIONS, post('/session/:sessionId/actions')],
237
[cmd.Name.CLEAR_ACTIONS, del('/session/:sessionId/actions')],
238
[cmd.Name.PRINT_PAGE, post('/session/:sessionId/print')],
239
240
// Locating elements.
241
[cmd.Name.GET_ACTIVE_ELEMENT, get('/session/:sessionId/element/active')],
242
[cmd.Name.FIND_ELEMENT, post('/session/:sessionId/element')],
243
[cmd.Name.FIND_ELEMENTS, post('/session/:sessionId/elements')],
244
[
245
cmd.Name.FIND_ELEMENTS_RELATIVE,
246
(cmd) => {
247
return toExecuteAtomCommand(cmd, Atom.FIND_ELEMENTS, 'findElements', 'args')
248
},
249
],
250
[cmd.Name.FIND_CHILD_ELEMENT, post('/session/:sessionId/element/:id/element')],
251
[cmd.Name.FIND_CHILD_ELEMENTS, post('/session/:sessionId/element/:id/elements')],
252
// Element interaction.
253
[cmd.Name.GET_ELEMENT_TAG_NAME, get('/session/:sessionId/element/:id/name')],
254
[cmd.Name.GET_DOM_ATTRIBUTE, get('/session/:sessionId/element/:id/attribute/:name')],
255
[
256
cmd.Name.GET_ELEMENT_ATTRIBUTE,
257
(cmd) => {
258
return toExecuteAtomCommand(cmd, Atom.GET_ATTRIBUTE, 'getAttribute', 'id', 'name')
259
},
260
],
261
[cmd.Name.GET_ELEMENT_PROPERTY, get('/session/:sessionId/element/:id/property/:name')],
262
[cmd.Name.GET_ELEMENT_VALUE_OF_CSS_PROPERTY, get('/session/:sessionId/element/:id/css/:propertyName')],
263
[cmd.Name.GET_ELEMENT_RECT, get('/session/:sessionId/element/:id/rect')],
264
[cmd.Name.CLEAR_ELEMENT, post('/session/:sessionId/element/:id/clear')],
265
[cmd.Name.CLICK_ELEMENT, post('/session/:sessionId/element/:id/click')],
266
[cmd.Name.SEND_KEYS_TO_ELEMENT, post('/session/:sessionId/element/:id/value')],
267
[cmd.Name.GET_ELEMENT_TEXT, get('/session/:sessionId/element/:id/text')],
268
[cmd.Name.GET_COMPUTED_ROLE, get('/session/:sessionId/element/:id/computedrole')],
269
[cmd.Name.GET_COMPUTED_LABEL, get('/session/:sessionId/element/:id/computedlabel')],
270
[cmd.Name.IS_ELEMENT_ENABLED, get('/session/:sessionId/element/:id/enabled')],
271
[cmd.Name.IS_ELEMENT_SELECTED, get('/session/:sessionId/element/:id/selected')],
272
273
[
274
cmd.Name.IS_ELEMENT_DISPLAYED,
275
(cmd) => {
276
return toExecuteAtomCommand(cmd, Atom.IS_DISPLAYED, 'isDisplayed', 'id')
277
},
278
],
279
280
// Cookie management.
281
[cmd.Name.GET_ALL_COOKIES, get('/session/:sessionId/cookie')],
282
[cmd.Name.ADD_COOKIE, post('/session/:sessionId/cookie')],
283
[cmd.Name.DELETE_ALL_COOKIES, del('/session/:sessionId/cookie')],
284
[cmd.Name.GET_COOKIE, get('/session/:sessionId/cookie/:name')],
285
[cmd.Name.DELETE_COOKIE, del('/session/:sessionId/cookie/:name')],
286
287
// Alert management.
288
[cmd.Name.ACCEPT_ALERT, post('/session/:sessionId/alert/accept')],
289
[cmd.Name.DISMISS_ALERT, post('/session/:sessionId/alert/dismiss')],
290
[cmd.Name.GET_ALERT_TEXT, get('/session/:sessionId/alert/text')],
291
[cmd.Name.SET_ALERT_TEXT, post('/session/:sessionId/alert/text')],
292
293
// Screenshots.
294
[cmd.Name.SCREENSHOT, get('/session/:sessionId/screenshot')],
295
[cmd.Name.TAKE_ELEMENT_SCREENSHOT, get('/session/:sessionId/element/:id/screenshot')],
296
297
// Shadow Root
298
[cmd.Name.GET_SHADOW_ROOT, get('/session/:sessionId/element/:id/shadow')],
299
[cmd.Name.FIND_ELEMENT_FROM_SHADOWROOT, post('/session/:sessionId/shadow/:id/element')],
300
[cmd.Name.FIND_ELEMENTS_FROM_SHADOWROOT, post('/session/:sessionId/shadow/:id/elements')],
301
// Log extensions.
302
[cmd.Name.GET_LOG, post('/session/:sessionId/se/log')],
303
[cmd.Name.GET_AVAILABLE_LOG_TYPES, get('/session/:sessionId/se/log/types')],
304
305
// Server Extensions
306
[cmd.Name.UPLOAD_FILE, post('/session/:sessionId/se/file')],
307
308
// Virtual Authenticator
309
[cmd.Name.ADD_VIRTUAL_AUTHENTICATOR, post('/session/:sessionId/webauthn/authenticator')],
310
[cmd.Name.REMOVE_VIRTUAL_AUTHENTICATOR, del('/session/:sessionId/webauthn/authenticator/:authenticatorId')],
311
[cmd.Name.ADD_CREDENTIAL, post('/session/:sessionId/webauthn/authenticator/:authenticatorId/credential')],
312
[cmd.Name.GET_CREDENTIALS, get('/session/:sessionId/webauthn/authenticator/:authenticatorId/credentials')],
313
[
314
cmd.Name.REMOVE_CREDENTIAL,
315
del('/session/:sessionId/webauthn/authenticator/:authenticatorId/credentials/:credentialId'),
316
],
317
[cmd.Name.REMOVE_ALL_CREDENTIALS, del('/session/:sessionId/webauthn/authenticator/:authenticatorId/credentials')],
318
[cmd.Name.SET_USER_VERIFIED, post('/session/:sessionId/webauthn/authenticator/:authenticatorId/uv')],
319
320
[cmd.Name.GET_DOWNLOADABLE_FILES, get('/session/:sessionId/se/files')],
321
[cmd.Name.DOWNLOAD_FILE, post(`/session/:sessionId/se/files`)],
322
[cmd.Name.DELETE_DOWNLOADABLE_FILES, del(`/session/:sessionId/se/files`)],
323
324
[cmd.Name.FIRE_SESSION_EVENT, post(`/session/:sessionId/se/event`)],
325
326
// Federated Credential Management Command
327
[cmd.Name.CANCEL_DIALOG, post(`/session/:sessionId/fedcm/canceldialog`)],
328
[cmd.Name.SELECT_ACCOUNT, post(`/session/:sessionId/fedcm/selectaccount`)],
329
[cmd.Name.GET_FEDCM_TITLE, get(`/session/:sessionId/fedcm/gettitle`)],
330
[cmd.Name.GET_FEDCM_DIALOG_TYPE, get('/session/:sessionId/fedcm/getdialogtype')],
331
[cmd.Name.SET_DELAY_ENABLED, post(`/session/:sessionId/fedcm/setdelayenabled`)],
332
[cmd.Name.RESET_COOLDOWN, post(`/session/:sessionId/fedcm/resetcooldown`)],
333
[cmd.Name.CLICK_DIALOG_BUTTON, post(`/session/:sessionId/fedcm/clickdialogbutton`)],
334
[cmd.Name.GET_ACCOUNTS, get(`/session/:sessionId/fedcm/accountlist`)],
335
])
336
337
/**
338
* Handles sending HTTP messages to a remote end.
339
*
340
* @interface
341
*/
342
class Client {
343
/**
344
* Sends a request to the server. The client will automatically follow any
345
* redirects returned by the server, fulfilling the returned promise with the
346
* final response.
347
*
348
* @param {!Request} httpRequest The request to send.
349
* @return {!Promise<Response>} A promise that will be fulfilled with the
350
* server's response.
351
*/
352
send(httpRequest) {}
353
}
354
355
/**
356
* @param {Map<string, CommandSpec>} customCommands
357
* A map of custom command definitions.
358
* @param {!cmd.Command} command The command to resolve.
359
* @return {!Request} A promise that will resolve with the
360
* command to execute.
361
*/
362
function buildRequest(customCommands, command) {
363
log_.finest(() => `Translating command: ${command.getName()}`)
364
let spec = customCommands && customCommands.get(command.getName())
365
if (spec) {
366
return toHttpRequest(spec)
367
}
368
369
spec = W3C_COMMAND_MAP.get(command.getName())
370
if (typeof spec === 'function') {
371
log_.finest(() => `Transforming command for W3C: ${command.getName()}`)
372
let newCommand = spec(command)
373
return buildRequest(customCommands, newCommand)
374
} else if (spec) {
375
return toHttpRequest(spec)
376
}
377
throw new error.UnknownCommandError('Unrecognized command: ' + command.getName())
378
379
/**
380
* @param {CommandSpec} resource
381
* @return {!Request}
382
*/
383
function toHttpRequest(resource) {
384
log_.finest(() => `Building HTTP request: ${JSON.stringify(resource)}`)
385
let parameters = command.getParameters()
386
let path = buildPath(resource.path, parameters)
387
return new Request(resource.method, path, parameters)
388
}
389
}
390
391
const CLIENTS = /** !WeakMap<!Executor, !(Client|IThenable<!Client>)> */ new WeakMap()
392
393
/**
394
* A command executor that communicates with the server using JSON over HTTP.
395
*
396
* By default, each instance of this class will use the legacy wire protocol
397
* from [Selenium project][json]. The executor will automatically switch to the
398
* [W3C wire protocol][w3c] if the remote end returns a compliant response to
399
* a new session command.
400
*
401
* [json]: https://github.com/SeleniumHQ/selenium/wiki/JsonWireProtocol
402
* [w3c]: https://w3c.github.io/webdriver/webdriver-spec.html
403
*
404
* @implements {cmd.Executor}
405
*/
406
class Executor {
407
/**
408
* @param {!(Client|IThenable<!Client>)} client The client to use for sending
409
* requests to the server, or a promise-like object that will resolve
410
* to the client.
411
*/
412
constructor(client) {
413
CLIENTS.set(this, client)
414
415
/** @private {Map<string, CommandSpec>} */
416
this.customCommands_ = null
417
418
/** @private {!logging.Logger} */
419
this.log_ = logging.getLogger(`${logging.Type.DRIVER}.http.Executor`)
420
}
421
422
/**
423
* Defines a new command for use with this executor. When a command is sent,
424
* the {@code path} will be preprocessed using the command's parameters; any
425
* path segments prefixed with ":" will be replaced by the parameter of the
426
* same name. For example, given "/person/:name" and the parameters
427
* "{name: 'Bob'}", the final command path will be "/person/Bob".
428
*
429
* @param {string} name The command name.
430
* @param {string} method The HTTP method to use when sending this command.
431
* @param {string} path The path to send the command to, relative to
432
* the WebDriver server's command root and of the form
433
* "/path/:variable/segment".
434
*/
435
defineCommand(name, method, path) {
436
if (!this.customCommands_) {
437
this.customCommands_ = new Map()
438
}
439
this.customCommands_.set(name, { method, path })
440
}
441
442
/** @override */
443
async execute(command) {
444
let request = buildRequest(this.customCommands_, command)
445
this.log_.finer(() => `>>> ${request.method} ${request.path}`)
446
447
let client = CLIENTS.get(this)
448
if (promise.isPromise(client)) {
449
client = await client
450
CLIENTS.set(this, client)
451
}
452
453
let response = await client.send(request)
454
this.log_.finer(() => `>>>\n${request}\n<<<\n${response}`)
455
456
let httpResponse = /** @type {!Response} */ (response)
457
458
let { isW3C, value } = parseHttpResponse(command, httpResponse)
459
460
if (command.getName() === cmd.Name.NEW_SESSION) {
461
if (!value || !value.sessionId) {
462
throw new error.WebDriverError(`Unable to parse new session response: ${response.body}`)
463
}
464
465
// The remote end is a W3C compliant server if there is no `status`
466
// field in the response.
467
if (command.getName() === cmd.Name.NEW_SESSION) {
468
this.w3c = this.w3c || isW3C
469
}
470
471
// No implementations use the `capabilities` key yet...
472
let capabilities = value.capabilities || value.value
473
return new Session(/** @type {{sessionId: string}} */ (value).sessionId, capabilities)
474
}
475
476
return typeof value === 'undefined' ? null : value
477
}
478
}
479
480
/**
481
* @param {string} str .
482
* @return {?} .
483
*/
484
function tryParse(str) {
485
try {
486
return JSON.parse(str)
487
/*eslint no-unused-vars: "off"*/
488
} catch (ignored) {
489
// Do nothing.
490
}
491
}
492
493
/**
494
* Callback used to parse {@link Response} objects from a
495
* {@link HttpClient}.
496
*
497
* @param {!cmd.Command} command The command the response is for.
498
* @param {!Response} httpResponse The HTTP response to parse.
499
* @return {{isW3C: boolean, value: ?}} An object describing the parsed
500
* response. This object will have two fields: `isW3C` indicates whether
501
* the response looks like it came from a remote end that conforms with the
502
* W3C WebDriver spec, and `value`, the actual response value.
503
* @throws {WebDriverError} If the HTTP response is an error.
504
*/
505
function parseHttpResponse(command, httpResponse) {
506
if (httpResponse.status < 200) {
507
// This should never happen, but throw the raw response so users report it.
508
throw new error.WebDriverError(`Unexpected HTTP response:\n${httpResponse}`)
509
}
510
511
let parsed = tryParse(httpResponse.body)
512
513
if (parsed && typeof parsed === 'object') {
514
let value = parsed.value
515
let isW3C = isObject(value) && typeof parsed.status === 'undefined'
516
517
if (!isW3C) {
518
error.checkLegacyResponse(parsed)
519
520
// Adjust legacy new session responses to look like W3C to simplify
521
// later processing.
522
if (command.getName() === cmd.Name.NEW_SESSION) {
523
value = parsed
524
}
525
} else if (httpResponse.status > 399) {
526
error.throwDecodedError(value)
527
}
528
529
return { isW3C, value }
530
}
531
532
if (parsed !== undefined) {
533
return { isW3C: false, value: parsed }
534
}
535
536
let value = httpResponse.body.replace(/\r\n/g, '\n')
537
538
// 404 represents an unknown command; anything else > 399 is a generic unknown
539
// error.
540
if (httpResponse.status === 404) {
541
throw new error.UnsupportedOperationError(command.getName() + ': ' + value)
542
} else if (httpResponse.status >= 400) {
543
throw new error.WebDriverError(value)
544
}
545
546
return { isW3C: false, value: value || null }
547
}
548
549
/**
550
* Builds a fully qualified path using the given set of command parameters. Each
551
* path segment prefixed with ':' will be replaced by the value of the
552
* corresponding parameter. All parameters spliced into the path will be
553
* removed from the parameter map.
554
* @param {string} path The original resource path.
555
* @param {!Object<*>} parameters The parameters object to splice into the path.
556
* @return {string} The modified path.
557
*/
558
function buildPath(path, parameters) {
559
let pathParameters = path.match(/\/:(\w+)\b/g)
560
if (pathParameters) {
561
for (let i = 0; i < pathParameters.length; ++i) {
562
let key = pathParameters[i].substring(2) // Trim the /:
563
if (key in parameters) {
564
let value = parameters[key]
565
if (webElement.isId(value)) {
566
// When inserting a WebElement into the URL, only use its ID value,
567
// not the full JSON.
568
value = webElement.extractId(value)
569
}
570
path = path.replace(pathParameters[i], '/' + value)
571
delete parameters[key]
572
} else {
573
throw new error.InvalidArgumentError('Missing required parameter: ' + key)
574
}
575
}
576
}
577
return path
578
}
579
580
// PUBLIC API
581
582
module.exports = {
583
Executor,
584
Client,
585
Request,
586
Response,
587
// Exported for testing.
588
buildPath,
589
}
590
591