nightwatch
Version:
Easy to use Node.js based end-to-end testing solution for web applications using the W3C WebDriver API.
135 lines (132 loc) • 5.3 kB
JavaScript
const ErrorCode = {
INSECURE_CERTIFICATE: 'insecure certificate',
ELEMENT_CLICK_INTERCEPTED: 'element click intercepted',
ELEMENT_IS_NOT_SELECTABLE: 'element not selectable',
ELEMENT_IS_NOT_INTERACTABLE: 'element not interactable',
INVALID_ARGUMENT: 'invalid argument',
INVALID_COOKIE_DOMAIN: 'invalid cookie domain',
INVALID_ELEMENT_COORDINATES: 'invalid coordinates',
INVALID_ELEMENT_STATE: 'invalid element state',
INVALID_SELECTOR: 'invalid selector',
NO_SUCH_SESSION: 'invalid session id',
JAVASCRIPT_ERROR: 'javascript error',
MOVE_TARGET_OUT_OF_BOUNDS: 'move target out of bounds',
NO_SUCH_ALERT: 'no such alert',
NO_SUCH_COOKIE: 'no such cookie',
NO_SUCH_ELEMENT: 'no such element',
NO_SUCH_FRAME: 'no such frame',
NO_SUCH_WINDOW: 'no such window',
SCRIPT_TIMEOUT: 'script timeout',
SESSION_NOT_CREATED_EXCEPTION: 'session not created',
STALE_ELEMENT_REFERENCE: 'stale element reference',
TIMEOUT: 'timeout',
UNABLE_TO_SET_COOKIE: 'unable to set cookie',
UNABLE_TO_CAPTURE_SCREEN: 'unable to capture screen',
UNEXPECTED_ALERT_OPEN: 'unexpected alert open',
UNKNOWN_COMMAND: 'unknown command',
UNKNOWN_ERROR: 'unknown error',
UNKNOWN_METHOD: 'unknown method',
UNSUPPORTED_OPERATION: 'unsupported operation'
};
const Errors = {
[]: {
message: 'A modal dialog was open, blocking this operation.'
},
[]: {
message: 'A new session could not be created.'
},
[]: {
message: 'An attempt was made to operate on a modal dialog when one was not open.'
},
[]: {
message: 'An element command could not be completed because the element is in an invalid state (e.g. attempting to click an element that is no longer attached to the document).'
},
[]: {
message: 'An element could not be located on the page using the given search parameters.'
},
[]: {
message: 'An error occurred while executing user supplied JavaScript.'
},
[]: {
message: 'An unknown server-side error occurred while processing the command.'
},
[]: {
message: 'No cookie matching the given path name was found amongst the cookies of the current active document.'
},
[]: {
message: 'The SSL certificate running on this host cannot be validated. ' +
'If you wish to force accepting insecure SSL certificates, set acceptInsecureCerts=true in the ' +
'desiredCapabilities options.'
},
[]: {
message: 'The arguments passed to the command are either invalid or malformed.'
},
[]: {
message: 'The arguments passed to the command are either invalid or malformed.'
},
[]: {
message: 'The command failed because the referenced element is no longer attached to the DOM.'
},
[]: {
message: 'The cookie domain name is not valid for the current page.'
},
[]: {
message: 'The coordinates provided to an interactions operation are invalid.'
},
[]: {
message: 'The element click command could not be completed because another element is receiving the click event.'
},
[]: {
message: 'The operation did not complete before its timeout expired.'
},
[]: {
message: 'The request to set a cookie\'s value could not be satisfied.'
},
[]: {
message: 'The requested command matched a known URL but did not match a method for that URL.'
},
[]: {
message: 'The requested element cannot be selected.'
},
[]: {
message: 'The requested element is not pointer or keyboard interactable.'
},
[]: {
message: 'The requested resource could not be found, or a request was received using an HTTP method that is not supported by the mapped resource.'
},
[]: {
message: 'The screen capture failed.'
},
[]: {
message: 'The script did not complete before its timeout expired.'
},
[]: {
message: 'The session is either terminated or not started.'
},
[]: {
message: 'The specified frame could not be found.'
},
[]: {
message: 'The specified window could not be found.'
},
[]: {
message: 'The supplied argument was an invalid selector (e.g. XPath/CSS).'
},
[]: {
message: 'The target for mouse interaction is not in the browser\'s viewport and cannot be brought into the viewport.'
},
[]: {
message: 'Unsupported operation exception.'
}
};
module.exports = {
findErrorById(statusCode) {
return {
status: statusCode,
id: statusCode,
message: Errors[statusCode].message
};
},
StatusCode: ErrorCode,
Response: Errors
};