add to firefoxdriver to path and fix some styling

This commit is contained in:
Dmitry Shibanov
2020-02-10 14:38:11 +03:00
parent 51e5139ff3
commit bf2aafad27

View File

@@ -4,6 +4,8 @@
################################################################################
Import-Module -Name ImageHelpers -Force
Import-Module -Name PathHelpers -Force
$temp_install_dir = 'C:\Windows\Installer'
New-Item -Path $temp_install_dir -ItemType Directory -Force
@@ -12,11 +14,11 @@ $latestVersion = $($versionsJson.LATEST_FIREFOX_VERSION)
Write-Host "Firefox latest version: $latestVersion"
# url for latest version of firefox
$urlLatestVersion = "https://download.mozilla.org/?product=firefox-latest&os=win64&lang=en-US"
$urlLatestVersion = "https://download.mozilla.org/?product=firefox-${latestVersion}&os=win64&lang=en-US"
Install-EXE -Url $urlLatestVersion -Name "Firefox Setup $latestVersion.exe" -ArgumentList ("/silent", "/install")
# Disable autoupdate
$firefoxDirectoryPath = '{0}\Program Files\Mozilla Firefox\' -f $env:SystemDrive;
$firefoxDirectoryPath = Join-Path $env:SystemDrive "Program Files\Mozilla Firefox"
New-Item -path $firefoxDirectoryPath -Name 'mozilla.cfg' -Value '//
pref("browser.shell.checkDefaultBrowser", false);
pref("app.update.enabled", false);' -ItemType file -force
@@ -26,7 +28,6 @@ New-Item -path $firefoxPreferencesFolder -Name 'local-settings.js' -Value 'pref(
pref("general.config.filename", "mozilla.cfg");' -ItemType file -force
Write-Host "Install Firefox WebDriver"
$DestinationPath = "$($env:SystemDrive)\";
$geckodriverJson = Invoke-RestMethod "https://api.github.com/repos/mozilla/geckodriver/releases/latest"
$geckodriverWindowsAsset = $geckodriverJson.assets | Where-Object { $_.name -Match "win64" } | Select-Object -First 1
@@ -35,9 +36,9 @@ Write-Host "Geckodriver version: $($geckodriverJson.tag_name)"
$DriversZipFile = $geckodriverWindowsAsset.name
Write-Host "Selenium drivers download and install...";
Write-Host "Selenium drivers download and install..."
$FirefoxDriverPath = "${DestinationPath}SeleniumWebDrivers\GeckoDriver";
$FirefoxDriverPath = Join-Path $env:SystemDrive "SeleniumWebDrivers\GeckoDriver"
# Install Firefox Web Driver
Write-Host "FireFox driver download...."
@@ -50,8 +51,8 @@ $EdgeDriverDownloadUrl = $geckodriverWindowsAsset.browser_download_url
try{
Invoke-WebRequest -Uri $EdgeDriverDownloadUrl -OutFile $DestFile
} catch {
Write-Error "[!] Failed to download $name";
exit 1;
Write-Error "[!] Failed to download $name"
exit 1
}
Write-Host "FireFox driver install...."
@@ -60,10 +61,10 @@ Remove-Item -Path $DestFile -Force
Write-Host "Setting the environment variables"
setx GeckoWebDriver "$FireFoxDriverPath" /M;
Add-MachinePathItem -PathItem $FireFoxDriverPath
$regEnvKey = 'HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\';
$PathValue = Get-ItemPropertyValue -Path $regEnvKey -Name 'Path';
$PathValue += ";$FireFoxDriverPath";
$regEnvKey = 'HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\'
$PathValue = Get-ItemPropertyValue -Path $regEnvKey -Name 'Path'
$PathValue += ";$FireFoxDriverPath"
Set-ItemProperty -Path $regEnvKey -Name 'Path' -Value $PathValue
exit 0;
exit 0