From 1a5aafd738352e4b7e73c7006668f37ac9f6812e Mon Sep 17 00:00:00 2001 From: Kazuaki Matsuo Date: Wed, 27 Mar 2024 20:18:30 -0700 Subject: [PATCH] chore: tune error handling with usePreinstalledWDA (#2368) * chore: add tey/ecatch to throw better error in error case * tune error message for simulator --- lib/driver.js | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/lib/driver.js b/lib/driver.js index 4230503ed..740cc16af 100644 --- a/lib/driver.js +++ b/lib/driver.js @@ -834,16 +834,20 @@ class XCUITestDriver extends BaseDriver { errorMsg += `. Make sure you follow the tutorial at ${WDA_REAL_DEV_TUTORIAL_URL}`; } if (this.opts.usePreinstalledWDA) { - // In case the bundle id process start got failed because of - // auth popup in the device. Then, the bundle id process itself started. It is safe to stop it here. - await this.mobileKillApp(this.wda.bundleIdForXctest); + try { + // In case the bundle id process start got failed because of + // auth popup in the device. Then, the bundle id process itself started. It is safe to stop it here. + await this.mobileKillApp(this.wda.bundleIdForXctest); + } catch (ign) {}; // Mostly it failed to start the WDA process as no the bundle id // e.g. ' not found on device ' - throw new Error( - `Unable to launch WebDriverAgent. Original error: ${err.message}. ` + - `Make sure the application ${this.wda.bundleIdForXctest} exists and it is launchable. ` + - `${WDA_REAL_DEV_TUTORIAL_URL} may help to complete the preparation.`, - ); + + errorMsg = `Unable to launch WebDriverAgent. Original error: ${err.message}. ` + + `Make sure the application ${this.wda.bundleIdForXctest} exists and it is launchable.`; + if (this.isRealDevice()) { + errorMsg += ` ${WDA_REAL_DEV_TUTORIAL_URL} may help to complete the preparation.`; + }; + throw new Error(errorMsg); } else { await quitAndUninstall(errorMsg); }