diff --git a/src/util/driverUtil.ts b/src/util/driverUtil.ts index 78863acb3..414992d2b 100644 --- a/src/util/driverUtil.ts +++ b/src/util/driverUtil.ts @@ -65,7 +65,7 @@ export class DriverUtil { } private getChromeDriverBinaryPath(version: string): string { - const majorVersion = version.split('.')[0]; + const majorVersion = this.getMajorVersion(version); const binary = process.platform === 'win32' ? 'chromedriver.exe' : 'chromedriver'; let driverBinaryPath = path.join(this.downloadFolder, binary); if (+majorVersion > 114) { @@ -75,9 +75,24 @@ export class DriverUtil { } static getChromeDriverPlatform(): string | undefined { + console.log(`This processor architecture is ${process.arch}`); switch (process.platform) { case 'darwin': return `mac-${process.arch}`; + case 'win32': + return process.arch === 'x64' ? 'win64' : 'win32'; + case 'linux': + return 'linux64'; + default: + break; + } + return undefined; + } + + private static getChromeDriverPlatformOLD(): string | undefined { + switch (process.platform) { + case 'darwin': + return `mac64`; case 'win32': return 'win32'; case 'linux': @@ -89,10 +104,11 @@ export class DriverUtil { } private getChromeDriverURL(version: string): string { - const majorVersion = version.split('.')[0]; - const driverPlatform = DriverUtil.getChromeDriverPlatform(); + const majorVersion = this.getMajorVersion(version); + let driverPlatform = DriverUtil.getChromeDriverPlatformOLD(); let url = `https://chromedriver.storage.googleapis.com/${version}/chromedriver_${driverPlatform}.zip`; if (+majorVersion > 114) { + driverPlatform = DriverUtil.getChromeDriverPlatform(); url = `https://edgedl.me.gvt1.com/edgedl/chrome/chrome-for-testing/${version}/${driverPlatform}/chromedriver-${driverPlatform}.zip` } return url; @@ -126,7 +142,7 @@ export class DriverUtil { * @param chromiumVersion Chromium version to check against */ private async getChromeDriverVersion(chromiumVersion: string): Promise { - const majorVersion = chromiumVersion.split('.')[0]; + const majorVersion = this.getMajorVersion(chromiumVersion); // chrome driver versioning has changed for chrome 70+ if (+majorVersion < 70) { @@ -145,6 +161,10 @@ export class DriverUtil { return fs.readFileSync(path.join(this.downloadFolder, fileName)).toString(); } + private getMajorVersion(version: string): string { + return version.split('.')[0]; + } + // older chromedriver versions do not match chrome versions private readonly chromiumVersionMap: VersionMap = { 69: '2.38',