Skip to content

Commit

Permalink
chore: tune error handling with usePreinstalledWDA (#2368)
Browse files Browse the repository at this point in the history
* chore: add tey/ecatch to throw better error in error case

* tune error message for simulator
  • Loading branch information
KazuCocoa authored Mar 28, 2024
1 parent ba54e38 commit 1a5aafd
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions lib/driver.js
Original file line number Diff line number Diff line change
Expand Up @@ -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. '<bundle id of WDA> not found on device <udid>'
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);
}
Expand Down

0 comments on commit 1a5aafd

Please sign in to comment.