fix geckodriver output

This commit is contained in:
Mikhail Timofeev
2020-03-06 01:04:14 +03:00
parent 5727a81299
commit e9e5323c93
4 changed files with 43 additions and 41 deletions

View File

@@ -94,3 +94,44 @@ $PathValue += ";$EdgeDriverPath\";
Set-ItemProperty -Path $regEnvKey -Name 'Path' -Value $PathValue;
exit 0;
# Install Firefox gecko Web Driver
Write-Host "Install Firefox WebDriver"
$geckodriverJson = Invoke-RestMethod "https://api.github.com/repos/mozilla/geckodriver/releases/latest"
$geckodriverWindowsAsset = $geckodriverJson.assets | Where-Object { $_.name -Match "win64" } | Select-Object -First 1
$geckodriverVersion = $geckodriverJson.tag_name
Write-Host "Geckodriver version: $geckodriverVersion"
$DriversZipFile = $geckodriverWindowsAsset.name
Write-Host "Selenium drivers download and install..."
$FirefoxDriverPath = Join-Path $SeleniumWebDriverPath "GeckoDriver"
$geckodriverVersion.Substring(1) | Out-File -FilePath "$FirefoxDriverPath\versioninfo.txt" -Force;
# Install Firefox Web Driver
Write-Host "FireFox driver download...."
if (-not (Test-Path -Path $FireFoxDriverPath)) {
New-Item -Path $FireFoxDriverPath -ItemType "directory"
}
$DestFile = Join-Path $FireFoxDriverPath $DriversZipFile
$FireFoxDriverDownloadUrl = $geckodriverWindowsAsset.browser_download_url
try{
Invoke-WebRequest -Uri $FireFoxDriverDownloadUrl -OutFile $DestFile
} catch {
Write-Error "[!] Failed to download $DriversZipFile"
exit 1
}
Write-Host "FireFox driver install...."
Expand-Archive -Path $DestFile -DestinationPath $FireFoxDriverPath -Force
Remove-Item -Path $DestFile -Force
Write-Host "Setting the environment variables"
Add-MachinePathItem -PathItem $FireFoxDriverPath
setx GeckoWebDriver "$FirefoxDriverPath" /M;
exit 0