Improve Windows browsers provisioners stability (#725)

* Improve Chrome provisioner

* Improve Edge provisioner

* Improve Firefox provisioner

* Resolve conflicts in Install-Chrome.ps1
This commit is contained in:
Maksim Petrov
2020-05-06 07:19:15 +03:00
committed by GitHub
parent 3fba9caa4f
commit 3f36d8ef35
3 changed files with 96 additions and 125 deletions

View File

@@ -5,37 +5,36 @@
Choco-Install -PackageName microsoft-edge
# Install Microsoft Edge Web Driver
Write-Host "Install Edge WebDriver"
$DestinationPath = "$($env:SystemDrive)\";
$EdgeDriverPath = "${DestinationPath}SeleniumWebDrivers\EdgeDriver"
if (-not (Test-Path -Path $EdgeDriverPath)) {
New-Item -Path $EdgeDriverPath -ItemType "directory"
# Install Microsoft Edge WebDriver
Write-Host "Install Edge WebDriver..."
$EdgeDriverPath = "$($env:SystemDrive)\SeleniumWebDrivers\EdgeDriver"
if (-not (Test-Path -Path $EdgeDriverPath))
{
New-Item -Path $EdgeDriverPath -ItemType Directory -Force
}
Write-Host "Get the Microsoft Edge WebDriver version..."
$RegistryPath = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths"
$EdgePath = (Get-ItemProperty "$RegistryPath\msedge.exe").'(default)'
[version]$EdgeVersion = [System.Diagnostics.FileVersionInfo]::GetVersionInfo($EdgePath).ProductVersion
$EdgeDriverVersionUrl = "https://msedgedriver.azureedge.net/LATEST_RELEASE_$($EdgeVersion.Major)"
$EdgeDriverVersionFile = "$EdgeDriverPath\versioninfo.txt"
Invoke-WebRequest -Uri $EdgeDriverVersionUrl -OutFile $EdgeDriverVersionFile
Write-Host "Microsoft Edge driver download started"
$EdgeDriverVersionFile = Start-DownloadWithRetry -Url $EdgeDriverVersionUrl -Name "versioninfo.txt" -DownloadPath $EdgeDriverPath
Write-Host "Download Microsoft Edge WebDriver..."
$EdgeDriverLatestVersion = Get-Content -Path $EdgeDriverVersionFile
$EdgeDriverDownloadUrl="https://msedgedriver.azureedge.net/${EdgeDriverLatestVersion}/edgedriver_win64.zip"
$DestFile = "$EdgeDriverPath\edgedriver_win64.zip"
Invoke-WebRequest -Uri $EdgeDriverDownloadUrl -OutFile $DestFile
$EdgeDriverArchName = "edgedriver_win64.zip"
$EdgeDriverDownloadUrl="https://msedgedriver.azureedge.net/${EdgeDriverLatestVersion}/${EdgeDriverArchName}"
Write-Host "Microsoft Edge driver installation started"
Expand-Archive -Path $DestFile -DestinationPath $EdgeDriverPath -Force
Remove-Item -Path $DestFile -Force
$EdgeDriverArchPath = Start-DownloadWithRetry -Url $EdgeDriverDownloadUrl -Name $EdgeDriverArchName
Write-Host "Setting the environment variables"
Write-Host "Expand Microsoft Edge WebDriver archive..."
Expand-Archive -Path $EdgeDriverArchPath -DestinationPath $EdgeDriverPath -Force
setx EdgeWebDriver "$EdgeDriverPath" /M;
Write-Host "Setting the environment variables..."
setx EdgeWebDriver "$EdgeDriverPath" /M
$regEnvKey = 'HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\';
$PathValue = Get-ItemPropertyValue -Path $regEnvKey -Name 'Path';
$PathValue += ";$EdgeDriverPath\";
Set-ItemProperty -Path $regEnvKey -Name 'Path' -Value $PathValue;
$regEnvKey = 'HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\'
$PathValue = Get-ItemPropertyValue -Path $regEnvKey -Name 'Path'
$PathValue += ";$EdgeDriverPath\"
Set-ItemProperty -Path $regEnvKey -Name 'Path' -Value $PathValue