MCPcopy Create free account
hub / github.com/SeleniumHQ/selenium / fromWireValue

Function fromWireValue

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

* Converts a value from its JSON representation according to the WebDriver wire * protocol. Any JSON object that defines a WebElement ID will be decoded to a * WebElement object. All other values will be passed through as is. * * @param {!WebDriver} driver The driver to use as the parent

(driver, value)

Source from the content-addressed store, hash-verified

211 * @return {*} The converted value.
212 */
213function fromWireValue(driver, value) {
214 if (Array.isArray(value)) {
215 value = value.map((v) => fromWireValue(driver, v))
216 } else if (WebElement.isId(value)) {
217 let id = WebElement.extractId(value)
218 value = new WebElement(driver, id)
219 } else if (ShadowRoot.isId(value)) {
220 let id = ShadowRoot.extractId(value)
221 value = new ShadowRoot(driver, id)
222 } else if (isObject(value)) {
223 let result = {}
224 for (let key in value) {
225 if (Object.prototype.hasOwnProperty.call(value, key)) {
226 result[key] = fromWireValue(driver, value[key])
227 }
228 }
229 value = result
230 }
231 return value
232}
233
234/**
235 * Resolves a wait message from either a function or a string.

Callers 1

executeMethod · 0.85

Calls 5

isObjectFunction · 0.70
callMethod · 0.65
mapMethod · 0.45
isIdMethod · 0.45
extractIdMethod · 0.45

Tested by

no test coverage detected