add to firefoxdriver to path and fix some styling
This commit is contained in:
@@ -4,6 +4,8 @@
|
|||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
Import-Module -Name ImageHelpers -Force
|
Import-Module -Name ImageHelpers -Force
|
||||||
|
Import-Module -Name PathHelpers -Force
|
||||||
|
|
||||||
$temp_install_dir = 'C:\Windows\Installer'
|
$temp_install_dir = 'C:\Windows\Installer'
|
||||||
New-Item -Path $temp_install_dir -ItemType Directory -Force
|
New-Item -Path $temp_install_dir -ItemType Directory -Force
|
||||||
|
|
||||||
@@ -12,11 +14,11 @@ $latestVersion = $($versionsJson.LATEST_FIREFOX_VERSION)
|
|||||||
Write-Host "Firefox latest version: $latestVersion"
|
Write-Host "Firefox latest version: $latestVersion"
|
||||||
|
|
||||||
# url for latest version of firefox
|
# 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")
|
Install-EXE -Url $urlLatestVersion -Name "Firefox Setup $latestVersion.exe" -ArgumentList ("/silent", "/install")
|
||||||
|
|
||||||
# Disable autoupdate
|
# 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 '//
|
New-Item -path $firefoxDirectoryPath -Name 'mozilla.cfg' -Value '//
|
||||||
pref("browser.shell.checkDefaultBrowser", false);
|
pref("browser.shell.checkDefaultBrowser", false);
|
||||||
pref("app.update.enabled", false);' -ItemType file -force
|
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
|
pref("general.config.filename", "mozilla.cfg");' -ItemType file -force
|
||||||
|
|
||||||
Write-Host "Install Firefox WebDriver"
|
Write-Host "Install Firefox WebDriver"
|
||||||
$DestinationPath = "$($env:SystemDrive)\";
|
|
||||||
|
|
||||||
$geckodriverJson = Invoke-RestMethod "https://api.github.com/repos/mozilla/geckodriver/releases/latest"
|
$geckodriverJson = Invoke-RestMethod "https://api.github.com/repos/mozilla/geckodriver/releases/latest"
|
||||||
$geckodriverWindowsAsset = $geckodriverJson.assets | Where-Object { $_.name -Match "win64" } | Select-Object -First 1
|
$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
|
$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
|
# Install Firefox Web Driver
|
||||||
Write-Host "FireFox driver download...."
|
Write-Host "FireFox driver download...."
|
||||||
@@ -50,8 +51,8 @@ $EdgeDriverDownloadUrl = $geckodriverWindowsAsset.browser_download_url
|
|||||||
try{
|
try{
|
||||||
Invoke-WebRequest -Uri $EdgeDriverDownloadUrl -OutFile $DestFile
|
Invoke-WebRequest -Uri $EdgeDriverDownloadUrl -OutFile $DestFile
|
||||||
} catch {
|
} catch {
|
||||||
Write-Error "[!] Failed to download $name";
|
Write-Error "[!] Failed to download $name"
|
||||||
exit 1;
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
Write-Host "FireFox driver install...."
|
Write-Host "FireFox driver install...."
|
||||||
@@ -60,10 +61,10 @@ Remove-Item -Path $DestFile -Force
|
|||||||
|
|
||||||
|
|
||||||
Write-Host "Setting the environment variables"
|
Write-Host "Setting the environment variables"
|
||||||
setx GeckoWebDriver "$FireFoxDriverPath" /M;
|
Add-MachinePathItem -PathItem $FireFoxDriverPath
|
||||||
|
|
||||||
$regEnvKey = 'HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\';
|
$regEnvKey = 'HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\'
|
||||||
$PathValue = Get-ItemPropertyValue -Path $regEnvKey -Name 'Path';
|
$PathValue = Get-ItemPropertyValue -Path $regEnvKey -Name 'Path'
|
||||||
$PathValue += ";$FireFoxDriverPath";
|
$PathValue += ";$FireFoxDriverPath"
|
||||||
Set-ItemProperty -Path $regEnvKey -Name 'Path' -Value $PathValue
|
Set-ItemProperty -Path $regEnvKey -Name 'Path' -Value $PathValue
|
||||||
exit 0;
|
exit 0
|
||||||
Reference in New Issue
Block a user