Skip to content

Instantly share code, notes, and snippets.

@yetanotherchris
Created November 3, 2015 12:36
Show Gist options
  • Save yetanotherchris/174f77be40e624f7c9ef to your computer and use it in GitHub Desktop.
Save yetanotherchris/174f77be40e624f7c9ef to your computer and use it in GitHub Desktop.
Determines the latest ChromeDriver from http://chromedriver.storage.googleapis.com/
#==========================================================================================
# 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