MCPcopy Index your code
hub / github.com/SeleniumHQ/selenium / send

Method send

javascript/selenium-webdriver/bidi/index.js:203–229  ·  view source on GitHub ↗

* Sends a bidi request * @param params * @returns {Promise }

(params)

Source from the content-addressed store, hash-verified

201 * @returns {Promise<unknown>}
202 */
203 async send(params) {
204 if (this._closed) {
205 throw new Error('BiDi connection is closed')
206 }
207 if (!this.connected) {
208 await this.waitForConnection()
209 }
210 // Defense in depth: even after waitForConnection() resolves, the socket
211 // may have transitioned to CLOSING/CLOSED (e.g. caller closed the raw
212 // socket). Refuse rather than throwing from inside ws.send().
213 if (this._ws.readyState !== WebSocket.OPEN) {
214 throw new Error('BiDi connection is not open')
215 }
216
217 const id = ++this.id
218
219 this._ws.send(JSON.stringify({ id, ...params }))
220
221 return new Promise((resolve, reject) => {
222 const timeoutId = setTimeout(() => {
223 this._pending.delete(id)
224 reject(new Error(`Request with id ${id} timed out`))
225 }, RESPONSE_TIMEOUT)
226
227 this._pending.set(id, { resolve, reject, timeoutId })
228 })
229 }
230
231 /**
232 * Subscribe to events

Callers 3

statusMethod · 0.95
subscribeMethod · 0.95
unsubscribeMethod · 0.95

Calls 5

waitForConnectionMethod · 0.95
sendMethod · 0.65
setMethod · 0.65
rejectFunction · 0.50
deleteMethod · 0.45

Tested by

no test coverage detected