From 61f8403c9bde726856c620f6f1002e157eb23308 Mon Sep 17 00:00:00 2001 From: Roman Kuznetsov Date: Wed, 20 Nov 2024 15:47:42 +0300 Subject: [PATCH] fix: apply edits --- src/browser-installer/registry/index.ts | 2 ++ src/browser-installer/run.ts | 2 ++ src/browser-pool/webdriver-pool.ts | 4 ++++ 3 files changed, 8 insertions(+) diff --git a/src/browser-installer/registry/index.ts b/src/browser-installer/registry/index.ts index c94211d8c..e5b600e04 100644 --- a/src/browser-installer/registry/index.ts +++ b/src/browser-installer/registry/index.ts @@ -159,6 +159,8 @@ export const getMatchedBrowserVersion = ( a = a.slice(a.indexOf("_") + 1); b = b.slice(b.indexOf("_") + 1); + // Firefox has versions like "stable_131.0a1" and "stable_129.0b9" + // Parsing raw numbers as hex values is needed in order to distinguish "129.0b9" and "129.0b7" for example return parseInt(a.replace(".", ""), 16) - parseInt(b.replace(".", ""), 16); }; diff --git a/src/browser-installer/run.ts b/src/browser-installer/run.ts index 71c442b13..9e3adc45c 100644 --- a/src/browser-installer/run.ts +++ b/src/browser-installer/run.ts @@ -15,5 +15,7 @@ export const runBrowserDriver = async ( return import("./firefox").then(module => module.runGeckoDriver(browserVersion, { debug })); case Driver.SAFARIDRIVER: return import("./safari").then(module => module.runSafariDriver({ debug })); + default: + throw new Error(`Invalid driver name: ${driverName}. Expected one of: ${Object.values(Driver).join(", ")}`); } }; diff --git a/src/browser-pool/webdriver-pool.ts b/src/browser-pool/webdriver-pool.ts index 413abdfd2..715acb6b3 100644 --- a/src/browser-pool/webdriver-pool.ts +++ b/src/browser-pool/webdriver-pool.ts @@ -32,6 +32,10 @@ export class WebdriverPool { ); } + if (!browserVersion) { + throw new Error(`Couldn't run browser driver for "${browserName}" because its version is undefined`); + } + const wdProcesses = this.driverProcess.get(driverName)?.get(browserVersion) ?? {}; for (const port in wdProcesses) {