From 4d38d84612e7e53742c75df2b4a4ff8fa27fd706 Mon Sep 17 00:00:00 2001 From: Andrey Lushnikov Date: Thu, 27 Jul 2023 05:53:45 -0700 Subject: [PATCH] test: fix chromedriver download URL (#24464) --- .../fixture-scripts/download-chromedriver.js | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/tests/installation/fixture-scripts/download-chromedriver.js b/tests/installation/fixture-scripts/download-chromedriver.js index a696ffa91b..ee57b62a02 100644 --- a/tests/installation/fixture-scripts/download-chromedriver.js +++ b/tests/installation/fixture-scripts/download-chromedriver.js @@ -1,6 +1,7 @@ const playwright = require('playwright-core'); const { execSync } = require('child_process'); const path = require('path'); +const fs = require('fs'); (async () => { const dir = process.argv[2]; @@ -10,13 +11,24 @@ const path = require('path'); console.log(`Found Chrome version ${version}`); const [major] = version.split('.'); - const driverVersion = execSync(`curl https://chromedriver.storage.googleapis.com/LATEST_RELEASE_${major} --silent`).toString('utf-8'); - console.log(`Found ChromeDriver version ${driverVersion}`); + const downloadsInfo = JSON.parse(execSync(`curl https://googlechromelabs.github.io/chrome-for-testing/latest-versions-per-milestone-with-downloads.json --silent`).toString('utf-8')); + + let currentPlatform = ''; + if (process.platform === 'darwin') + currentPlatform = process.arch === 'arm64' ? 'mac-arm64' : 'mac-x64'; + else if (process.platform === 'linux') + currentPlatform = 'linux64'; + else + currentPlatform = 'win64'; + const chromeDriverURL = downloadsInfo.milestones[major].downloads.chromedriver.find(({ platform, url }) => platform === currentPlatform).url; + console.log(`Found ChromeDriver download URL: ${chromeDriverURL}`); const zip = path.join(dir, 'chromedriver.zip'); - execSync(`curl https://chromedriver.storage.googleapis.com/${driverVersion}/chromedriver_${process.platform === 'darwin' ? 'mac' : 'linux'}64.zip --output ${zip} --silent`); + execSync(`curl ${chromeDriverURL} --output ${zip} --silent`); console.log(`Downloaded ${zip}`); execSync(`unzip ${zip}`, { cwd: dir }); console.log(`Unzipped ${zip}`); + + fs.renameSync(`chromedriver-${currentPlatform}`, `chromedriver`); })();