Files
runner-images/images/windows/scripts/build/Install-EdgeDriver.ps1
kishorekumar-anchala 42e65904de [windows] Replace WebClient with Invoke-WebRequest & Update EdgeDrive Thumbprint (#12390)
* [windows] Update EdgeDriver signature

* feat: Improve temp directory handling and update file download method

- Added check for \ existence before accessing it.
- If the directory does not exist, it is now created.
- Replaced System.Net.WebClient with Invoke-WebRequest for file downloads, improving compatibility and maintainability.

Co-authored-by: Subir0071 <subir0071@github.com>

* [Windows] Remove check for TEMP_Dir

---------

Co-authored-by: Subir0071 <subir0071@github.com>
2025-06-17 08:33:00 -06:00

42 lines
2.1 KiB
PowerShell

################################################################################
## File: Install-EdgeDriver.ps1
## Desc: Install Edge WebDriver and configure Microsoft Edge
################################################################################
# Disable Edge auto-updates
Rename-Item -Path "C:\Program Files (x86)\Microsoft\EdgeUpdate\MicrosoftEdgeUpdate.exe" -NewName "Disabled_MicrosoftEdgeUpdate.exe" -ErrorAction Stop
Write-Host "Get the Microsoft Edge WebDriver version..."
$edgeBinaryPath = (Get-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\msedge.exe").'(default)'
[version] $edgeVersion = [System.Diagnostics.FileVersionInfo]::GetVersionInfo($edgeBinaryPath).ProductVersion
$edgeDriverPath = "$($env:SystemDrive)\SeleniumWebDrivers\EdgeDriver"
if (-not (Test-Path -Path $edgeDriverPath)) {
New-Item -Path $edgeDriverPath -ItemType Directory -Force
}
$versionInfoUrl = "https://msedgedriver.azureedge.net/LATEST_RELEASE_$($edgeVersion.Major)_WINDOWS"
$versionInfoFile = Invoke-DownloadWithRetry -Url $versionInfoUrl -Path "$edgeDriverPath\versioninfo.txt"
$latestVersion = Get-Content -Path $versionInfoFile
Write-Host "Download Microsoft Edge WebDriver..."
$downloadUrl = "https://msedgedriver.azureedge.net/$latestVersion/edgedriver_win64.zip"
$archivePath = Invoke-DownloadWithRetry $downloadUrl
Write-Host "Expand Microsoft Edge WebDriver archive..."
Expand-7ZipArchive -Path $archivePath -DestinationPath $edgeDriverPath
#Validate the EdgeDriver signature
$signatureThumbprint = @(
"7920AC8FB05E0FFFE21E8FF4B4F03093BA6AC16E",
"0BD8C56733FDCC06F8CB919FF5A200E39B1ACF71",
"F6EECCC7FF116889C2D5466AE7243D7AA7698689"
)
Test-FileSignature -Path "$edgeDriverPath\msedgedriver.exe" -ExpectedThumbprint $signatureThumbprint
Write-Host "Setting the environment variables..."
[Environment]::SetEnvironmentVariable("EdgeWebDriver", $EdgeDriverPath, "Machine")
Add-MachinePathItem "$edgeDriverPath\"
Invoke-PesterTests -TestFile "Browsers" -TestName "Edge"