mirror of
https://github.com/actions/runner-images-sangeeth.git
synced 2025-12-20 06:29:50 +00:00
Post-review code modification
This commit is contained in:
@@ -3,40 +3,48 @@
|
||||
## Desc: Install Selenium Web Drivers
|
||||
################################################################################
|
||||
$DestinationPath = "C:\";
|
||||
Write-Debug "Destination path: [$DestinationPath]";
|
||||
Write-Debug "Selenium drivers download and install...";
|
||||
Invoke-WebRequest -UseBasicParsing -Uri "https://seleniumwebdrivers.blob.core.windows.net/seleniumwebdrivers/SeleniumWebDrivers.zip" -OutFile SeleniumWebDrivers.zip;
|
||||
Expand-Archive -Path SeleniumWebDrivers.zip -DestinationPath $DestinationPath -Force;
|
||||
Remove-Item SeleniumWebDrivers.zip;
|
||||
$DriversZipFile = "SeleniumWebDrivers.zip"
|
||||
Write-Host "Destination path: [$DestinationPath]";
|
||||
Write-Host "Selenium drivers download and install...";
|
||||
try {
|
||||
Invoke-WebRequest -UseBasicParsing -Uri "https://seleniumwebdrivers.blob.core.windows.net/seleniumwebdrivers/${DriversZipFile}" -OutFile $DriversZipFile;
|
||||
}
|
||||
catch {
|
||||
Write-Error "[!] Failed to download $DriverZipFile";
|
||||
exit 1;
|
||||
}
|
||||
|
||||
Expand-Archive -Path $DriversZipFile -DestinationPath $DestinationPath -Force;
|
||||
Remove-Item $DriversZipFile;
|
||||
|
||||
$ChromeDriverPath = "$DestinationPath\SeleniumWebDrivers\ChromeDriver";
|
||||
Write-Debug "Chrome driver path: [$ChromeDriverPath]";
|
||||
Write-Host "Chrome driver path: [$ChromeDriverPath]";
|
||||
Remove-Item -Path "$ChromeDriverPath\*" -Force;
|
||||
|
||||
$ChromePath = (Get-ItemProperty 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\chrome.exe').'(default)';
|
||||
[version]$ChromeVersion = [System.Diagnostics.FileVersionInfo]::GetVersionInfo($ChromePath).ProductVersion;
|
||||
Write-Debug "Chrome version: [$ChromeVersion]";
|
||||
Write-Host "Chrome version: [$ChromeVersion]";
|
||||
|
||||
$ChromeDriverVersionUri = "https://chromedriver.storage.googleapis.com/LATEST_RELEASE_$($ChromeVersion.Major).$($ChromeVersion.Minor).$($ChromeVersion.Build)";
|
||||
Write-Debug "Chrome driver version Uri [$ChromeDriverVersionUri]";
|
||||
Write-Debug "Getting the Chrome driver version...";
|
||||
Write-Host "Chrome driver version Uri [$ChromeDriverVersionUri]";
|
||||
Write-Host "Getting the Chrome driver version...";
|
||||
$ChromeDriverVersion = Invoke-WebRequest -Uri $ChromeDriverVersionUri;
|
||||
Write-Debug "Current Chrome driver version: [$ChromeDriverVersion]";
|
||||
Write-Host "Current Chrome driver version: [$ChromeDriverVersion]";
|
||||
|
||||
$ChromeDriverZipDownloadUri = "https://chromedriver.storage.googleapis.com/$($ChromeDriverVersion.ToString())/chromedriver_win32.zip";
|
||||
Write-Debug "Chrome driver zip file download Uri: [$ChromeDriverZipDownloadUri]";
|
||||
Write-Host "Chrome driver zip file download Uri: [$ChromeDriverZipDownloadUri]";
|
||||
|
||||
$DestFile= "$ChromeDriverPath\chromedriver_win32.zip";
|
||||
$ChromeDriverVersion.Content | Out-File -FilePath "$ChromeDriverPath\versioninfo.txt" -Force;
|
||||
|
||||
Write-Debug "Chrome driver download....";
|
||||
Write-Host "Chrome driver download....";
|
||||
Invoke-WebRequest -Uri $ChromeDriverZipDownloadUri -OutFile $DestFile;
|
||||
|
||||
Write-Debug "Chrome driver install....";
|
||||
Write-Host "Chrome driver install....";
|
||||
Expand-Archive -Path "$ChromeDriverPath\chromedriver_win32.zip" -DestinationPath $ChromeDriverPath -Force;
|
||||
Remove-Item -Path "$ChromeDriverPath\chromedriver_win32.zip" -Force;
|
||||
|
||||
Write-Debug "Setting the environment variables";
|
||||
Write-Host "Setting the environment variables";
|
||||
|
||||
setx IEWebDriver "C:\SeleniumWebDrivers\IEDriver" /M;
|
||||
setx GeckoWebDriver "C:\SeleniumWebDrivers\GeckoDriver" /M;
|
||||
|
||||
Reference in New Issue
Block a user