Skip to content

Commit

Permalink
Support Chrome for Testing on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
nanasess committed Jul 26, 2023
1 parent 170469a commit 031f9d9
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 9 deletions.
13 changes: 10 additions & 3 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,16 @@ jobs:
run: |
$chrome_fullversion = (Get-Item $Env:CHROMEAPP).VersionInfo.FileVersion
$chrome_majorversion = $chrome_fullversion.Split(".")[0]
$response = Invoke-WebRequest "http://chromedriver.storage.googleapis.com/LATEST_RELEASE_$chrome_majorversion"
$version = $response.Content
echo "CHROMEDRIVER_VERSION=$version" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf-8 -Append
if($chrome_majorversion -lt 115)
{
$response = Invoke-WebRequest "http://chromedriver.storage.googleapis.com/LATEST_RELEASE_$chrome_majorversion"
$version = $response.Content
echo "CHROMEDRIVER_VERSION=$version" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf-8 -Append
}
else
{
echo "CHROMEDRIVER_VERSION=$chrome_fullversion" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf-8 -Append
}
- uses: ./
if: matrix.branch == 'now'
with:
Expand Down
33 changes: 27 additions & 6 deletions lib/setup-chromedriver.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,36 @@ Param(
[string]$version
)

$chrome_fullversion = (Get-Item "C:\Program Files\Google\Chrome\Application\chrome.exe").VersionInfo.FileVersion

Write-Output "Chrome version: $chrome_fullversion"
if([string]::IsNullOrEmpty($version))
{
$chrome_fullversion = (Get-Item "C:\Program Files\Google\Chrome\Application\chrome.exe").VersionInfo.FileVersion
$chrome_majorversion = $chrome_fullversion.Split(".")[0]
}
else
{
$chrome_majorversion = $version.Split(".")[0]
}
if($chrome_majorversion -lt 115)
{
$response = Invoke-WebRequest "http://chromedriver.storage.googleapis.com/LATEST_RELEASE_$chrome_majorversion"
$version = $response.Content
Invoke-WebRequest "https://chromedriver.storage.googleapis.com/$version/chromedriver_win32.zip" -OutFile chromedriver_win32.zip
Expand-Archive -Path chromedriver_win32.zip -DestinationPath C:\SeleniumWebDrivers\ChromeDriver -Force
Remove-Item chromedriver_win32.zip
}
else
{
if([string]::IsNullOrEmpty($version))
{
$version = $chrome_fullversion
}
$arch = "win32"
Write-Output $arch
$url = Invoke-WebRequest "https://googlechromelabs.github.io/chrome-for-testing/known-good-versions-with-downloads.json" -UseBasicParsing | ConvertFrom-Json | Select-Object -ExpandProperty versions | Where-Object { $_.version -eq $version } | Select-Object -ExpandProperty downloads | Select-Object -ExpandProperty chromedriver | Where-Object { $_.platform -eq $arch } | Select-Object -ExpandProperty url
Invoke-WebRequest $url -OutFile chromedriver-win32.zip
Expand-Archive -Path chromedriver-win32.zip -Force
Move-Item -Path .\chromedriver-win32\chromedriver-win32\chromedriver.exe -Destination C:\SeleniumWebDrivers\ChromeDriver -Force
Remove-Item chromedriver-win32.zip
}

Invoke-WebRequest "https://chromedriver.storage.googleapis.com/$version/chromedriver_win32.zip" -OutFile chromedriver_win32.zip

Expand-Archive -Path chromedriver_win32.zip -DestinationPath C:\SeleniumWebDrivers\ChromeDriver -Force
Remove-Item chromedriver_win32.zip

0 comments on commit 031f9d9

Please sign in to comment.