From e97e32a7ef35c8ab03befb937b022324b60398a7 Mon Sep 17 00:00:00 2001 From: Priyansh Garg Date: Wed, 17 Apr 2024 22:30:47 +0530 Subject: [PATCH] Keep error's original messages for NoSuchElementError. --- lib/transport/errors/index.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/transport/errors/index.js b/lib/transport/errors/index.js index 903084358d..5f5e2ccd80 100644 --- a/lib/transport/errors/index.js +++ b/lib/transport/errors/index.js @@ -155,11 +155,13 @@ module.exports = { if (err && (err.name in SeleniumNightwatchErrorCodeMap)) { const statusCode = SeleniumNightwatchErrorCodeMap[err.name]; - return { - ...err, - ...Errors[statusCode], - id: statusCode - }; + for (const [key, value] of Object.entries(Errors[statusCode])) { + err[key] ||= value; + } + + err.id = statusCode; + + return err; } else if (err && err.name && (err.stack || err.stackTrace)){ return err; }