test: fix chromedriver download URL (#24464)

This commit is contained in:
Andrey Lushnikov 2023-07-27 05:53:45 -07:00 committed by GitHub
parent 7524894512
commit 4d38d84612
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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`);
})();