2020-01-31 10:43:55 +03:00
|
|
|
################################################################################
|
2023-11-16 11:20:11 +01:00
|
|
|
## File: Install-EdgeDriver.ps1
|
|
|
|
|
## Desc: Install Edge WebDriver and configure Microsoft Edge
|
2020-01-31 10:43:55 +03:00
|
|
|
################################################################################
|
|
|
|
|
|
2023-07-11 12:21:46 +02:00
|
|
|
# Disable Edge auto-updates
|
2024-01-09 20:05:02 +01:00
|
|
|
Rename-Item -Path "C:\Program Files (x86)\Microsoft\EdgeUpdate\MicrosoftEdgeUpdate.exe" -NewName "Disabled_MicrosoftEdgeUpdate.exe" -ErrorAction Stop
|
2023-07-11 12:21:46 +02:00
|
|
|
|
2020-05-06 07:19:15 +03:00
|
|
|
Write-Host "Get the Microsoft Edge WebDriver version..."
|
2023-11-29 13:02:29 +01:00
|
|
|
$edgeBinaryPath = (Get-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\msedge.exe").'(default)'
|
|
|
|
|
[version] $edgeVersion = [System.Diagnostics.FileVersionInfo]::GetVersionInfo($edgeBinaryPath).ProductVersion
|
2022-02-14 12:07:00 +03:00
|
|
|
|
2023-11-29 13:02:29 +01:00
|
|
|
$edgeDriverPath = "$($env:SystemDrive)\SeleniumWebDrivers\EdgeDriver"
|
|
|
|
|
if (-not (Test-Path -Path $edgeDriverPath)) {
|
|
|
|
|
New-Item -Path $edgeDriverPath -ItemType Directory -Force
|
|
|
|
|
}
|
2023-10-11 11:02:59 +02:00
|
|
|
|
2023-11-29 13:02:29 +01:00
|
|
|
$versionInfoUrl = "https://msedgedriver.azureedge.net/LATEST_RELEASE_$($edgeVersion.Major)_WINDOWS"
|
|
|
|
|
$versionInfoFile = Invoke-DownloadWithRetry -Url $versionInfoUrl -Path "$edgeDriverPath\versioninfo.txt"
|
|
|
|
|
$latestVersion = Get-Content -Path $versionInfoFile
|
2020-03-06 13:33:25 +03:00
|
|
|
|
2023-11-29 13:02:29 +01:00
|
|
|
Write-Host "Download Microsoft Edge WebDriver..."
|
|
|
|
|
$downloadUrl = "https://msedgedriver.azureedge.net/$latestVersion/edgedriver_win64.zip"
|
|
|
|
|
$archivePath = Invoke-DownloadWithRetry $downloadUrl
|
2020-03-06 13:33:25 +03:00
|
|
|
|
2020-05-06 07:19:15 +03:00
|
|
|
Write-Host "Expand Microsoft Edge WebDriver archive..."
|
2023-11-29 13:02:29 +01:00
|
|
|
Expand-7ZipArchive -Path $archivePath -DestinationPath $edgeDriverPath
|
2020-03-06 13:33:25 +03:00
|
|
|
|
2023-10-11 11:02:59 +02:00
|
|
|
#Validate the EdgeDriver signature
|
2024-11-10 19:36:23 +00:00
|
|
|
$signatureThumbprint = "7920AC8FB05E0FFFE21E8FF4B4F03093BA6AC16E"
|
2023-11-30 09:22:14 +01:00
|
|
|
Test-FileSignature -Path "$edgeDriverPath\msedgedriver.exe" -ExpectedThumbprint $signatureThumbprint
|
2023-10-11 11:02:59 +02:00
|
|
|
|
2020-05-06 07:19:15 +03:00
|
|
|
Write-Host "Setting the environment variables..."
|
2023-11-17 13:52:52 +01:00
|
|
|
[Environment]::SetEnvironmentVariable("EdgeWebDriver", $EdgeDriverPath, "Machine")
|
2023-11-29 13:02:29 +01:00
|
|
|
Add-MachinePathItem "$edgeDriverPath\"
|
2020-07-10 14:29:54 +03:00
|
|
|
|
2021-09-06 18:58:11 +03:00
|
|
|
Invoke-PesterTests -TestFile "Browsers" -TestName "Edge"
|