Revert "Try installing Google Chrome for Testing (#7997)" (#8190)

This reverts commit d9169bba1e.
This commit is contained in:
Alexey-Ayupov
2023-08-29 21:42:30 +02:00
committed by GitHub
parent 49ea494d52
commit 36ddc88274
2 changed files with 75 additions and 29 deletions
@@ -3,43 +3,80 @@
## Desc: Install Google Chrome ## Desc: Install Google Chrome
################################################################################ ################################################################################
# Get versions info # Download and install latest Chrome browser
$ChromeVersionsUrl = "https://googlechromelabs.github.io/chrome-for-testing/last-known-good-versions-with-downloads.json" $ChromeInstallerFile = "googlechromestandaloneenterprise64.msi"
$ChromeVersions = Invoke-RestMethod -Uri $ChromeVersionsUrl $ChromeInstallerUrl = "https://dl.google.com/tag/s/dl/chrome/install/${ChromeInstallerFile}"
$ChromeVersionInfo = $ChromeVersions.channels.Stable Install-Binary -Url $ChromeInstallerUrl -Name $ChromeInstallerFile -ArgumentList @()
# Install Google Chrome for Testing # Prepare firewall rules
$ChromeVersion = $ChromeVersionInfo.version Write-Host "Adding the firewall rule for Google update blocking..."
$ChromeUrl = ($ChromeVersionInfo.downloads.chrome | Where-Object platform -eq "win64").url New-NetFirewallRule -DisplayName "BlockGoogleUpdate" -Direction Outbound -Action Block -Program "C:\Program Files (x86)\Google\Update\GoogleUpdate.exe"
Write-Host "Installing Google Chrome for Testing version $ChromeVersion" $GoogleSvcs = ('gupdate','gupdatem')
$ChromePath = "$($env:SystemDrive)\Program Files\Google\Chrome" $GoogleSvcs | Stop-SvcWithErrHandling -StopOnError
if (-not (Test-Path -Path $ChromePath)) { $GoogleSvcs | Set-SvcWithErrHandling -Arguments @{StartupType = "Disabled"}
New-Item -Path $ChromePath -ItemType Directory -Force
$regGoogleUpdatePath = "HKLM:\SOFTWARE\Policies\Google\Update"
$regGoogleUpdateChrome = "HKLM:\SOFTWARE\Policies\Google\Chrome"
($regGoogleUpdatePath, $regGoogleUpdateChrome) | ForEach-Object {
New-Item -Path $_ -Force
} }
$ChromeArchivePath = Start-DownloadWithRetry -Url $ChromeUrl $regGoogleParameters = @(
Extract-7Zip -Path $ChromeArchivePath -DestinationPath $ChromePath @{ Name = "AutoUpdateCheckPeriodMinutes"; Value = 00000000},
Rename-Item "$ChromePath\chrome-win64" "$ChromePath\Application" @{ Name = "UpdateDefault"; Value = 00000000 },
@{ Name = "DisableAutoUpdateChecksCheckboxValue"; Value = 00000001 },
@{ Name = "Update{8A69D345-D564-463C-AFF1-A69D9E530F96}"; Value = 00000000 },
@{ Path = $regGoogleUpdateChrome; Name = "DefaultBrowserSettingEnabled"; Value = 00000000 }
)
$chromeRegPath = "HKLM:SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\chrome.exe" $regGoogleParameters | ForEach-Object {
New-Item $chromeRegPath $Arguments = $_
Set-ItemProperty $chromeRegPath "(default)" "$ChromePath\Application\chrome.exe" if (-not ($Arguments.Path))
{
$Arguments.Add("Path", $regGoogleUpdatePath)
}
$Arguments.Add("Force", $true)
New-ItemProperty @Arguments
}
# Install Chrome Driver # Install Chrome WebDriver
$ChromeDriverVersion = $ChromeVersionInfo.version Write-Host "Install Chrome WebDriver..."
$ChromeDriverUrl = ($ChromeVersionInfo.downloads.chromedriver | Where-Object platform -eq "win64").url
Write-Host "Installing ChromeDriver version $ChromeDriverVersion"
$ChromeDriverPath = "$($env:SystemDrive)\SeleniumWebDrivers\ChromeDriver" $ChromeDriverPath = "$($env:SystemDrive)\SeleniumWebDrivers\ChromeDriver"
if (-not (Test-Path -Path $ChromeDriverPath)) { if (-not (Test-Path -Path $ChromeDriverPath))
{
New-Item -Path $ChromeDriverPath -ItemType Directory -Force New-Item -Path $ChromeDriverPath -ItemType Directory -Force
} }
$ChromeDriverVersion | Out-File -FilePath "$ChromeDriverPath\versioninfo.txt" -Force; Write-Host "Get the Chrome WebDriver download URL..."
$ChromeDriverArchivePath = Start-DownloadWithRetry -Url $ChromeDriverUrl $RegistryPath = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths"
Extract-7Zip -Path $ChromeDriverArchivePath -DestinationPath $ChromeDriverPath -ExtractMethod "e" $ChromePath = (Get-ItemProperty "$RegistryPath\chrome.exe").'(default)'
[version]$ChromeVersion = [System.Diagnostics.FileVersionInfo]::GetVersionInfo($ChromePath).ProductVersion
$ChromeBuild = "$($ChromeVersion.Major).$($ChromeVersion.Minor).$($ChromeVersion.Build)"
$ChromeDriverVersionsUrl = "https://googlechromelabs.github.io/chrome-for-testing/latest-patch-versions-per-build-with-downloads.json"
Write-Host "Chrome version is $ChromeVersion"
$ChromeDriverVersions = Invoke-RestMethod -Uri $ChromeDriverVersionsUrl
$ChromeDriverVersion = $ChromeDriverVersions.builds.$ChromeBuild
if (-not ($ChromeDriverVersion)) {
$availableVersions = $ChromeDriverVersions.builds | Get-Member | Select-Object -ExpandProperty Name
Write-Host "Available chromedriver builds are $availableVersions"
Throw "Can't determine chromedriver version that matches chrome build $ChromeBuild"
}
$ChromeDriverVersion.version | Out-File -FilePath "$ChromeDriverPath\versioninfo.txt" -Force;
Write-Host "Chrome WebDriver version to install is $($ChromeDriverVersion.version)"
$ChromeDriverZipDownloadUrl = ($ChromeDriverVersion.downloads.chromedriver | Where-Object platform -eq "win64").url
Write-Host "Download Chrome WebDriver from $ChromeDriverZipDownloadUrl..."
$ChromeDriverArchPath = Start-DownloadWithRetry -Url $ChromeDriverZipDownloadUrl
Write-Host "Expand Chrome WebDriver archive (without using directory names)..."
Extract-7Zip -Path $ChromeDriverArchPath -DestinationPath $ChromeDriverPath -ExtractMethod "e"
Write-Host "Setting the environment variables..."
setx ChromeWebDriver "$ChromeDriverPath" /M setx ChromeWebDriver "$ChromeDriverPath" /M
$regEnvKey = 'HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\' $regEnvKey = 'HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\'
+12 -3
View File
@@ -28,9 +28,18 @@ Describe "Chrome" {
$versionInfo | Should -Not -BeNullOrEmpty $versionInfo | Should -Not -BeNullOrEmpty
} }
It "Chrome Product Name should be 'Google Chrome for Testing'" -TestCases @{chromePath = $chromePath } { It "gupdate service is stopped" {
$productName = (Get-Item $chromePath).VersionInfo.ProductName $svc = Get-Service -Name gupdate
$productName | Should -BeExactly "Google Chrome for Testing" $svc.Status | Should -BeExactly Stopped
}
It "gupdatem service is stopped" {
$svc = Get-Service -Name gupdatem
$svc.Status | Should -BeExactly Stopped
}
It "BlockGoogleUpdate firewall rule exists" {
Get-NetFirewallRule -DisplayName BlockGoogleUpdate | Should -Not -BeNullOrEmpty
} }
It "<chromePath> is installed" -TestCases @{chromePath = $chromePath} { It "<chromePath> is installed" -TestCases @{chromePath = $chromePath} {