Created
November 3, 2015 12:36
-
-
Save yetanotherchris/174f77be40e624f7c9ef to your computer and use it in GitHub Desktop.
Determines the latest ChromeDriver from http://chromedriver.storage.googleapis.com/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#========================================================================================== | |
# Get the latest Chromedriver version number | |
#========================================================================================== | |
WriteHeader "Determining Chromedriver version" | |
$url = "http://chromedriver.storage.googleapis.com/"; | |
$xml = [xml](wget $url); | |
$chromeDriver_version = 2.12; | |
# XML format: <ListBucketResult><Contents><Key>...</Key></Contents></ListBucketResult> | |
foreach ($item in $xml.ListBucketResult.Contents) | |
{ | |
$value = $item.Key; | |
if ([string]::IsNullOrEmpty($value) -eq $false) | |
{ | |
# The format of the value is "2.10/chromedriver-xyz.zip" | |
if ($value.Contains("/")) | |
{ | |
$value = $value.Substring(0, $value.IndexOf("/")); | |
} | |
# Fix ChromeDriver's broken versioning (it has 2.9 as higher than 2.17, when it should be 2.09) | |
if ($value.Contains(".") -and $value.Contains(".1") -eq $false) | |
{ | |
$value = $value.Replace(".", ".0"); | |
} | |
# Try to parse the number | |
$numberValue = 0; | |
[decimal]::TryParse($value, [ref] $numberValue) | Out-Null | |
if ($numberValue -gt $chromeDriver_version ) | |
{ | |
$chromeDriver_version = $numberValue; | |
} | |
} | |
} | |
Write-Host "Current ChromeDriver is: $chromeDriver_version "; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment