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

Function checkLegacyResponse

javascript/selenium-webdriver/lib/error.js:541–564  ·  view source on GitHub ↗

* Checks a legacy response from the Selenium 2.0 wire protocol for an error. * @param {*} responseObj the response object to check. * @return {*} responseObj the original response if it does not define an error. * @throws {WebDriverError} if the response object defines an error.

(responseObj)

Source from the content-addressed store, hash-verified

539 * @throws {WebDriverError} if the response object defines an error.
540 */
541function checkLegacyResponse(responseObj) {
542 // Handle the legacy Selenium error response format.
543 if (isObject(responseObj) && typeof responseObj.status === 'number' && responseObj.status !== 0) {
544 const { status, value } = responseObj
545
546 let ctor = LEGACY_ERROR_CODE_TO_TYPE.get(status) || WebDriverError
547
548 if (!value || typeof value !== 'object') {
549 throw new ctor(value + '')
550 } else {
551 let message = value['message'] + ''
552 if (ctor !== UnexpectedAlertOpenError) {
553 throw new ctor(message)
554 }
555
556 let text = ''
557 if (value['alert'] && typeof value['alert']['text'] === 'string') {
558 text = value['alert']['text']
559 }
560 throw new UnexpectedAlertOpenError(message, text)
561 }
562 }
563 return responseObj
564}
565
566// PUBLIC API
567

Callers

nothing calls this directly

Calls 2

isObjectFunction · 0.70
getMethod · 0.65

Tested by

no test coverage detected