Skip to content

Commit d6a2d4d

Browse files
authored
Merge pull request #71 from tech-sushant/fix-1305
fix: handle existing scan name error and improve WebDriver Init
2 parents a8568d4 + ac4a770 commit d6a2d4d

File tree

3 files changed

+23
-7
lines changed

3 files changed

+23
-7
lines changed

src/tools/accessiblity-utils/scanner.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,11 @@ export class AccessibilityScanner {
8383
return data;
8484
} catch (err) {
8585
if (axios.isAxiosError(err) && err.response?.data) {
86+
if (err.response.status === 422) {
87+
throw new Error(
88+
"A scan with this name already exists. please update the name and run again.",
89+
);
90+
}
8691
const msg =
8792
(err.response.data as any).error ||
8893
(err.response.data as any).message ||

src/tools/appautomate.ts

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -104,13 +104,20 @@ async function takeAppScreenshot(args: {
104104
};
105105

106106
logger.info("Starting WebDriver session on BrowserStack...");
107-
driver = await remote({
108-
protocol: "https",
109-
hostname: "hub.browserstack.com",
110-
port: 443,
111-
path: "/wd/hub",
112-
capabilities,
113-
});
107+
try {
108+
driver = await remote({
109+
protocol: "https",
110+
hostname: "hub.browserstack.com",
111+
port: 443,
112+
path: "/wd/hub",
113+
capabilities,
114+
});
115+
} catch (error) {
116+
logger.error("Error initializing WebDriver:", error);
117+
throw new Error(
118+
"Failed to initialize the WebDriver or a timeout occurred. Please try again.",
119+
);
120+
}
114121

115122
const screenshotBase64 = await driver.takeScreenshot();
116123
const compressed = await maybeCompressBase64(screenshotBase64);

src/tools/applive-utils/start-session.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,10 @@ export async function startSession(args: StartSessionArgs): Promise<string> {
6464
const { app_url } = await uploadApp(appPath);
6565
logger.info(`App uploaded: ${app_url}`);
6666

67+
if (!app_url) {
68+
throw new Error("Failed to upload app. Please try again.");
69+
}
70+
6771
// 7) Build URL & open
6872
const deviceParam = sanitizeUrlParam(
6973
selected.display_name.replace(/\s+/g, "+"),

0 commit comments

Comments
 (0)