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

Function toWireValue

javascript/selenium-webdriver/lib/webdriver.js:148–172  ·  view source on GitHub ↗

* Converts an object to its JSON representation in the WebDriver wire protocol. * When converting values of type object, the following steps will be taken: * * if the object is a WebElement, the return value will be the element's * server ID * if the object defines a {@link Sym

(obj)

Source from the content-addressed store, hash-verified

146 * representation.
147 */
148async function toWireValue(obj) {
149 let value = await Promise.resolve(obj)
150 if (value === void 0 || value === null) {
151 return value
152 }
153
154 if (typeof value === 'boolean' || typeof value === 'number' || typeof value === 'string') {
155 return value
156 }
157
158 if (Array.isArray(value)) {
159 return convertKeys(value)
160 }
161
162 if (typeof value === 'function') {
163 return '' + value
164 }
165
166 if (typeof value[Symbols.serialize] === 'function') {
167 return toWireValue(value[Symbols.serialize]())
168 } else if (typeof value.toJSON === 'function') {
169 return toWireValue(value.toJSON())
170 }
171 return convertKeys(value)
172}
173
174async function convertKeys(obj) {
175 const isArray = Array.isArray(obj)

Callers 3

executeCommandFunction · 0.85
convertKeysFunction · 0.85
executeMethod · 0.85

Calls 2

convertKeysFunction · 0.85
toJSONMethod · 0.45

Tested by

no test coverage detected