From e3df777d31a7c802c16f077c396ae338e7a76d5d Mon Sep 17 00:00:00 2001 From: Dmitry Shibanov <“shibanov-1997@inbox.ru”> Date: Thu, 6 Feb 2020 19:31:18 +0300 Subject: [PATCH 01/14] add installation --- .../scripts/Installers/Install-Firefox.ps1 | 67 ++++++++++++++++++- .../Installers/Install-SeleniumWebDrivers.ps1 | 2 +- 2 files changed, 66 insertions(+), 3 deletions(-) diff --git a/images/win/scripts/Installers/Install-Firefox.ps1 b/images/win/scripts/Installers/Install-Firefox.ps1 index 560c7148..2ab7a66f 100644 --- a/images/win/scripts/Installers/Install-Firefox.ps1 +++ b/images/win/scripts/Installers/Install-Firefox.ps1 @@ -4,11 +4,19 @@ ################################################################################ Import-Module -Name ImageHelpers -Force - +# https://github.com/mozilla/geckodriver/releases/latest - geckodriver for firefox $temp_install_dir = 'C:\Windows\Installer' New-Item -Path $temp_install_dir -ItemType Directory -Force -Install-EXE -Url "https://seleniumwebdrivers.blob.core.windows.net/knownfirefoxversion/FirefoxSetup.exe" -Name "FirefoxSetup.exe" -ArgumentList "-ms" +$firefoxJson = Invoke-WebRequest "https://product-details.mozilla.org/1.0/firefox_versions.json" | ConvertFrom-Json + +Write-Host "Firefox json" +Write-Host $firefoxJson + +$latestVersion = $($firefoxJson.LATEST_FIREFOX_VERSION) +Write-Host "Firefox latest version $latestVersion" + +Install-EXE -Url "https://seleniumwebdrivers.blob.core.windows.net/knownfirefoxversion/FirefoxSetup.exe" -Name "Firefox Setup $latestVersion" -ArgumentList "-ms" $path = '{0}\Program Files\Mozilla Firefox\' -f $env:SystemDrive; New-Item -path $path -Name 'mozilla.cfg' -Value '// @@ -18,3 +26,58 @@ pref("app.update.enabled", false);' -ItemType file -force $path = '{0}\Program Files\Mozilla Firefox\defaults\pref\' -f $env:SystemDrive; New-Item -path $path -Name 'local-settings.js' -Value 'pref("general.config.obscure_value", 0); pref("general.config.filename", "mozilla.cfg");' -ItemType file -force + +# section for installing selenium web driver +Write-Host "Install selenium" + +gci env:* | sort-object name + +$DestinationPath = "$($env:SystemDrive)\"; + +$geckodriverJson = Invoke-RestMethod "https://api.github.com/repos/mozilla/geckodriver/releases/latest" + $geckodriverJson.assets | ForEach-Object -Process { + if ($_.name -Match "win64") + { + $name = $_.name + $adress = $_.browser_download_url + } + } + + +Write-Host "Name of firefox zip file $name" +Write-Host "Install url $adress" + +$DriversZipFile = $name +Write-Host "Destination path: [$DestinationPath]"; +Write-Host "Selenium drivers download and install..."; + +$FireFoxDriverPath = "${DestinationPath}SeleniumWebDrivers\GeckoDriver"; + +# Install Fire Fox Web Driver +Write-Host "FireFox driver download...." +if (-not (Test-Path -Path $FireFoxDriverPath)) { + New-Item -Path $FireFoxDriverPath -ItemType "directory" +} + +$DestFile = "$FireFoxDriverPath\$name" +$EdgeDriverDownloadUrl = $adress +try{ + Invoke-WebRequest -Uri $EdgeDriverDownloadUrl -OutFile $DestFile +} catch { + Write-Error "[!] Failed to download $name"; + 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" +setx GeckoWebDriver "$FireFoxDriverPath" /M; + +$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; \ No newline at end of file diff --git a/images/win/scripts/Installers/Install-SeleniumWebDrivers.ps1 b/images/win/scripts/Installers/Install-SeleniumWebDrivers.ps1 index c6e1b3c2..aadae2c8 100644 --- a/images/win/scripts/Installers/Install-SeleniumWebDrivers.ps1 +++ b/images/win/scripts/Installers/Install-SeleniumWebDrivers.ps1 @@ -10,7 +10,7 @@ try { Invoke-WebRequest -UseBasicParsing -Uri "https://seleniumwebdrivers.blob.core.windows.net/seleniumwebdrivers/${DriversZipFile}" -OutFile $DriversZipFile; } catch { - Write-Error "[!] Failed to download $DriverZipFile"; + Write-Error "[!] Failed to download $DriversZipFile"; exit 1; } From e9b593d44427313e2b322bf765597441a202a3ed Mon Sep 17 00:00:00 2001 From: Dmitry Shibanov <“shibanov-1997@inbox.ru”> Date: Fri, 7 Feb 2020 11:19:14 +0300 Subject: [PATCH 02/14] some clean up changes --- .../scripts/Installers/Install-Firefox.ps1 | 52 +++++++------------ 1 file changed, 19 insertions(+), 33 deletions(-) diff --git a/images/win/scripts/Installers/Install-Firefox.ps1 b/images/win/scripts/Installers/Install-Firefox.ps1 index 2ab7a66f..3406b206 100644 --- a/images/win/scripts/Installers/Install-Firefox.ps1 +++ b/images/win/scripts/Installers/Install-Firefox.ps1 @@ -4,63 +4,49 @@ ################################################################################ Import-Module -Name ImageHelpers -Force -# https://github.com/mozilla/geckodriver/releases/latest - geckodriver for firefox $temp_install_dir = 'C:\Windows\Installer' New-Item -Path $temp_install_dir -ItemType Directory -Force -$firefoxJson = Invoke-WebRequest "https://product-details.mozilla.org/1.0/firefox_versions.json" | ConvertFrom-Json +$versionsJson = Invoke-WebRequest "https://product-details.mozilla.org/1.0/firefox_versions.json" | ConvertFrom-Json +$latestVersion = $($versionsJson.LATEST_FIREFOX_VERSION) +Write-Host "Firefox latest version: $latestVersion" -Write-Host "Firefox json" -Write-Host $firefoxJson +# url for latest version of firefox +$urlLatestVersion = "https://download.mozilla.org/?product=firefox-latest&os=win64&lang=en-US" +Install-EXE -Url $urlLatestVersion -Name "Firefox Setup $latestVersion" -ArgumentList ("/silent", "/install") -$latestVersion = $($firefoxJson.LATEST_FIREFOX_VERSION) -Write-Host "Firefox latest version $latestVersion" - -Install-EXE -Url "https://seleniumwebdrivers.blob.core.windows.net/knownfirefoxversion/FirefoxSetup.exe" -Name "Firefox Setup $latestVersion" -ArgumentList "-ms" - -$path = '{0}\Program Files\Mozilla Firefox\' -f $env:SystemDrive; -New-Item -path $path -Name 'mozilla.cfg' -Value '// +# Disable autoupdate +$firefoxDirectoryPath = '{0}\Program Files\Mozilla Firefox\' -f $env:SystemDrive; +New-Item -path $firefoxDirectoryPath -Name 'mozilla.cfg' -Value '// pref("browser.shell.checkDefaultBrowser", false); pref("app.update.enabled", false);' -ItemType file -force -$path = '{0}\Program Files\Mozilla Firefox\defaults\pref\' -f $env:SystemDrive; -New-Item -path $path -Name 'local-settings.js' -Value 'pref("general.config.obscure_value", 0); +$firefoxPreferencesFolder = Join-Path $firefoxDirectoryPath "defaults\pref" +New-Item -path $firefoxPreferencesFolder -Name 'local-settings.js' -Value 'pref("general.config.obscure_value", 0); pref("general.config.filename", "mozilla.cfg");' -ItemType file -force -# section for installing selenium web driver -Write-Host "Install selenium" - -gci env:* | sort-object name - +Write-Host "Install Firefox WebDriver" $DestinationPath = "$($env:SystemDrive)\"; $geckodriverJson = Invoke-RestMethod "https://api.github.com/repos/mozilla/geckodriver/releases/latest" - $geckodriverJson.assets | ForEach-Object -Process { - if ($_.name -Match "win64") - { - $name = $_.name - $adress = $_.browser_download_url - } - } +$geckodriverWindowsAsset = $geckodriverJson.assets | Where-Object { $_.name -Match "win64" } | Select-Object -First 1 + +Write-Host "Geckodriver version: $($geckodriverJson.tag_name)" -Write-Host "Name of firefox zip file $name" -Write-Host "Install url $adress" - -$DriversZipFile = $name -Write-Host "Destination path: [$DestinationPath]"; +$DriversZipFile = $geckodriverWindowsAsset.name Write-Host "Selenium drivers download and install..."; -$FireFoxDriverPath = "${DestinationPath}SeleniumWebDrivers\GeckoDriver"; +$FirefoxDriverPath = "${DestinationPath}SeleniumWebDrivers\GeckoDriver"; -# Install Fire Fox Web Driver +# Install Firefox Web Driver Write-Host "FireFox driver download...." if (-not (Test-Path -Path $FireFoxDriverPath)) { New-Item -Path $FireFoxDriverPath -ItemType "directory" } $DestFile = "$FireFoxDriverPath\$name" -$EdgeDriverDownloadUrl = $adress +$EdgeDriverDownloadUrl = $geckodriverWindowsAsset.browser_download_url try{ Invoke-WebRequest -Uri $EdgeDriverDownloadUrl -OutFile $DestFile } catch { From 081946423a0cc3e4bcc3b1404a01def31c017af7 Mon Sep 17 00:00:00 2001 From: Dmitry Shibanov <“shibanov-1997@inbox.ru”> Date: Sun, 9 Feb 2020 23:59:59 +0300 Subject: [PATCH 03/14] minor changes --- images/win/scripts/Installers/Install-Firefox.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/images/win/scripts/Installers/Install-Firefox.ps1 b/images/win/scripts/Installers/Install-Firefox.ps1 index 3406b206..b3850d44 100644 --- a/images/win/scripts/Installers/Install-Firefox.ps1 +++ b/images/win/scripts/Installers/Install-Firefox.ps1 @@ -13,7 +13,7 @@ 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" -Install-EXE -Url $urlLatestVersion -Name "Firefox Setup $latestVersion" -ArgumentList ("/silent", "/install") +Install-EXE -Url $urlLatestVersion -Name "Firefox Setup $latestVersion.exe" -ArgumentList "ms" # Disable autoupdate $firefoxDirectoryPath = '{0}\Program Files\Mozilla Firefox\' -f $env:SystemDrive; From 51e5139ff310786828f509107793bea91f35f792 Mon Sep 17 00:00:00 2001 From: Dmitry Shibanov <“shibanov-1997@inbox.ru”> Date: Mon, 10 Feb 2020 09:31:59 +0300 Subject: [PATCH 04/14] add new arguments --- images/win/scripts/Installers/Install-Firefox.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/images/win/scripts/Installers/Install-Firefox.ps1 b/images/win/scripts/Installers/Install-Firefox.ps1 index b3850d44..228c6284 100644 --- a/images/win/scripts/Installers/Install-Firefox.ps1 +++ b/images/win/scripts/Installers/Install-Firefox.ps1 @@ -13,7 +13,7 @@ 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" -Install-EXE -Url $urlLatestVersion -Name "Firefox Setup $latestVersion.exe" -ArgumentList "ms" +Install-EXE -Url $urlLatestVersion -Name "Firefox Setup $latestVersion.exe" -ArgumentList ("/silent", "/install") # Disable autoupdate $firefoxDirectoryPath = '{0}\Program Files\Mozilla Firefox\' -f $env:SystemDrive; From bf2aafad27564e9657c3b632b5b2f2c678132a02 Mon Sep 17 00:00:00 2001 From: Dmitry Shibanov Date: Mon, 10 Feb 2020 14:38:11 +0300 Subject: [PATCH 05/14] add to firefoxdriver to path and fix some styling --- .../scripts/Installers/Install-Firefox.ps1 | 25 ++++++++++--------- 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/images/win/scripts/Installers/Install-Firefox.ps1 b/images/win/scripts/Installers/Install-Firefox.ps1 index 228c6284..d818b28b 100644 --- a/images/win/scripts/Installers/Install-Firefox.ps1 +++ b/images/win/scripts/Installers/Install-Firefox.ps1 @@ -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; \ No newline at end of file +exit 0 \ No newline at end of file From d53d34e11558c20b214eef3907757d7ce6dc4051 Mon Sep 17 00:00:00 2001 From: Dmitry Shibanov Date: Mon, 10 Feb 2020 15:24:01 +0300 Subject: [PATCH 06/14] remove extra lines --- images/win/scripts/Installers/Install-Firefox.ps1 | 4 ---- 1 file changed, 4 deletions(-) diff --git a/images/win/scripts/Installers/Install-Firefox.ps1 b/images/win/scripts/Installers/Install-Firefox.ps1 index d818b28b..6ba79f09 100644 --- a/images/win/scripts/Installers/Install-Firefox.ps1 +++ b/images/win/scripts/Installers/Install-Firefox.ps1 @@ -63,8 +63,4 @@ Remove-Item -Path $DestFile -Force Write-Host "Setting the environment variables" Add-MachinePathItem -PathItem $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 \ No newline at end of file From 371369c4b20e8e5f622f2a9a8f5ebcf7b0cf6d2b Mon Sep 17 00:00:00 2001 From: Dmitry Shibanov Date: Tue, 11 Feb 2020 11:08:28 +0300 Subject: [PATCH 07/14] fix name --- images/win/scripts/Installers/Install-Firefox.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/images/win/scripts/Installers/Install-Firefox.ps1 b/images/win/scripts/Installers/Install-Firefox.ps1 index 6ba79f09..cb6f8e81 100644 --- a/images/win/scripts/Installers/Install-Firefox.ps1 +++ b/images/win/scripts/Installers/Install-Firefox.ps1 @@ -46,12 +46,12 @@ if (-not (Test-Path -Path $FireFoxDriverPath)) { New-Item -Path $FireFoxDriverPath -ItemType "directory" } -$DestFile = "$FireFoxDriverPath\$name" +$DestFile = "$FireFoxDriverPath\$DriversZipFile" $EdgeDriverDownloadUrl = $geckodriverWindowsAsset.browser_download_url try{ Invoke-WebRequest -Uri $EdgeDriverDownloadUrl -OutFile $DestFile } catch { - Write-Error "[!] Failed to download $name" + Write-Error "[!] Failed to download $DriversZipFile" exit 1 } From 03d0e3d1c6aa3cf1df5637af0f992110ad90996f Mon Sep 17 00:00:00 2001 From: Dmitry Shibanov Date: Tue, 11 Feb 2020 12:39:39 +0300 Subject: [PATCH 08/14] resolve comments --- images/win/scripts/Installers/Install-Firefox.ps1 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/images/win/scripts/Installers/Install-Firefox.ps1 b/images/win/scripts/Installers/Install-Firefox.ps1 index cb6f8e81..14c4763e 100644 --- a/images/win/scripts/Installers/Install-Firefox.ps1 +++ b/images/win/scripts/Installers/Install-Firefox.ps1 @@ -10,7 +10,7 @@ $temp_install_dir = 'C:\Windows\Installer' New-Item -Path $temp_install_dir -ItemType Directory -Force $versionsJson = Invoke-WebRequest "https://product-details.mozilla.org/1.0/firefox_versions.json" | ConvertFrom-Json -$latestVersion = $($versionsJson.LATEST_FIREFOX_VERSION) +$latestVersion = $versionsJson.LATEST_FIREFOX_VERSION Write-Host "Firefox latest version: $latestVersion" # url for latest version of firefox @@ -18,7 +18,7 @@ $urlLatestVersion = "https://download.mozilla.org/?product=firefox-${latestVersi Install-EXE -Url $urlLatestVersion -Name "Firefox Setup $latestVersion.exe" -ArgumentList ("/silent", "/install") # Disable autoupdate -$firefoxDirectoryPath = Join-Path $env:SystemDrive "Program Files\Mozilla Firefox" +$firefoxDirectoryPath = Join-Path $env:ProgramFiles "Mozilla Firefox" New-Item -path $firefoxDirectoryPath -Name 'mozilla.cfg' -Value '// pref("browser.shell.checkDefaultBrowser", false); pref("app.update.enabled", false);' -ItemType file -force @@ -46,7 +46,7 @@ if (-not (Test-Path -Path $FireFoxDriverPath)) { New-Item -Path $FireFoxDriverPath -ItemType "directory" } -$DestFile = "$FireFoxDriverPath\$DriversZipFile" +$DestFile = Join-Path $FireFoxDriverPath $DriversZipFile $EdgeDriverDownloadUrl = $geckodriverWindowsAsset.browser_download_url try{ Invoke-WebRequest -Uri $EdgeDriverDownloadUrl -OutFile $DestFile From d72263d6c1781c404535811c4347e40eb9b52176 Mon Sep 17 00:00:00 2001 From: Dmitry Shibanov <“shibanov-1997@inbox.ru”> Date: Tue, 11 Feb 2020 13:02:27 +0300 Subject: [PATCH 09/14] replace web request to rest method --- images/win/scripts/Installers/Install-Firefox.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/images/win/scripts/Installers/Install-Firefox.ps1 b/images/win/scripts/Installers/Install-Firefox.ps1 index 14c4763e..ff70fc78 100644 --- a/images/win/scripts/Installers/Install-Firefox.ps1 +++ b/images/win/scripts/Installers/Install-Firefox.ps1 @@ -9,7 +9,7 @@ Import-Module -Name PathHelpers -Force $temp_install_dir = 'C:\Windows\Installer' New-Item -Path $temp_install_dir -ItemType Directory -Force -$versionsJson = Invoke-WebRequest "https://product-details.mozilla.org/1.0/firefox_versions.json" | ConvertFrom-Json +$versionsJson = Invoke-RestMethod "https://product-details.mozilla.org/1.0/firefox_versions.json" $latestVersion = $versionsJson.LATEST_FIREFOX_VERSION Write-Host "Firefox latest version: $latestVersion" From e4cee0c52769a6de43dbdd81914a0c7b82fdb32e Mon Sep 17 00:00:00 2001 From: Dmitry Shibanov <“shibanov-1997@inbox.ru”> Date: Wed, 12 Feb 2020 18:02:47 +0300 Subject: [PATCH 10/14] move directories to other folder --- .../win/scripts/Installers/Install-Firefox.ps1 | 5 ++--- .../Installers/Install-SeleniumWebDrivers.ps1 | 16 +++++++++++----- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/images/win/scripts/Installers/Install-Firefox.ps1 b/images/win/scripts/Installers/Install-Firefox.ps1 index ff70fc78..abf234cb 100644 --- a/images/win/scripts/Installers/Install-Firefox.ps1 +++ b/images/win/scripts/Installers/Install-Firefox.ps1 @@ -4,7 +4,6 @@ ################################################################################ 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 @@ -47,9 +46,9 @@ if (-not (Test-Path -Path $FireFoxDriverPath)) { } $DestFile = Join-Path $FireFoxDriverPath $DriversZipFile -$EdgeDriverDownloadUrl = $geckodriverWindowsAsset.browser_download_url +$FireFoxDriverDownloadUrl = $geckodriverWindowsAsset.browser_download_url try{ - Invoke-WebRequest -Uri $EdgeDriverDownloadUrl -OutFile $DestFile + Invoke-WebRequest -Uri $FireFoxDriverDownloadUrl -OutFile $DestFile } catch { Write-Error "[!] Failed to download $DriversZipFile" exit 1 diff --git a/images/win/scripts/Installers/Install-SeleniumWebDrivers.ps1 b/images/win/scripts/Installers/Install-SeleniumWebDrivers.ps1 index aadae2c8..d1febb46 100644 --- a/images/win/scripts/Installers/Install-SeleniumWebDrivers.ps1 +++ b/images/win/scripts/Installers/Install-SeleniumWebDrivers.ps1 @@ -14,12 +14,19 @@ catch { exit 1; } -Expand-Archive -Path $DriversZipFile -DestinationPath $DestinationPath -Force; -Remove-Item $DriversZipFile; +Expand-Archive -Path $DriversZipFile -DestinationPath $env:TEMP -Force; +$SeleniumWebDriverPath = Join-Path $DestinationPath "SeleniumWebDrivers" +Remove-Item $DriversZipFile; $ChromeDriverPath = "${DestinationPath}SeleniumWebDrivers\ChromeDriver"; -Write-Host "Chrome driver path: [$ChromeDriverPath]"; -Remove-Item -Path "$ChromeDriverPath\*" -Force; +$EdgeDriverPathTemp = Join-Path $Env:TEMP 'EdgeDriver' +$IEDriverPathTemp = Join-Path $Env:TEMP 'IEDriver' +$ChromeDriverPathTemp = Join-Path $Env:TEMP 'ChromeDriver' +Remove-Item -Path "$ChromeDriverPathTemp\*" -Force; +Move-Item -Path "$EdgeDriverPathTemp" -Destination $SeleniumWebDriverPath +Move-Item -Path "$IEDriverPathTemp" -Destination $SeleniumWebDriverPath +Move-Item -Path "$ChromeDriverPathTemp" -Destination $SeleniumWebDriverPath + # Reinstall Chrome Web Driver $RegistryPath = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths" @@ -71,7 +78,6 @@ Remove-Item -Path $DestFile -Force Write-Host "Setting the environment variables" setx IEWebDriver "C:\SeleniumWebDrivers\IEDriver" /M; -setx GeckoWebDriver "C:\SeleniumWebDrivers\GeckoDriver" /M; setx ChromeWebDriver "$ChromeDriverPath" /M; setx EdgeWebDriver "$EdgeDriverPath" /M; From 0fabec1bb808f61fa80d8916ea0837a5cd485820 Mon Sep 17 00:00:00 2001 From: Dmitry Shibanov Date: Wed, 12 Feb 2020 19:03:32 +0300 Subject: [PATCH 11/14] minor changes --- .../Installers/Install-SeleniumWebDrivers.ps1 | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/images/win/scripts/Installers/Install-SeleniumWebDrivers.ps1 b/images/win/scripts/Installers/Install-SeleniumWebDrivers.ps1 index d1febb46..0af2145e 100644 --- a/images/win/scripts/Installers/Install-SeleniumWebDrivers.ps1 +++ b/images/win/scripts/Installers/Install-SeleniumWebDrivers.ps1 @@ -14,21 +14,17 @@ catch { exit 1; } -Expand-Archive -Path $DriversZipFile -DestinationPath $env:TEMP -Force; +$TempSeleniumDir = Join-Path $Env:TEMP "SeleniumWebDrivers" +Expand-Archive -Path $DriversZipFile -DestinationPath $Env:TEMP -Force; +Remove-Item $DriversZipFile; $SeleniumWebDriverPath = Join-Path $DestinationPath "SeleniumWebDrivers" -Remove-Item $DriversZipFile; -$ChromeDriverPath = "${DestinationPath}SeleniumWebDrivers\ChromeDriver"; -$EdgeDriverPathTemp = Join-Path $Env:TEMP 'EdgeDriver' -$IEDriverPathTemp = Join-Path $Env:TEMP 'IEDriver' -$ChromeDriverPathTemp = Join-Path $Env:TEMP 'ChromeDriver' -Remove-Item -Path "$ChromeDriverPathTemp\*" -Force; -Move-Item -Path "$EdgeDriverPathTemp" -Destination $SeleniumWebDriverPath +$IEDriverPathTemp = Join-Path $TempSeleniumDir 'IEDriver' Move-Item -Path "$IEDriverPathTemp" -Destination $SeleniumWebDriverPath -Move-Item -Path "$ChromeDriverPathTemp" -Destination $SeleniumWebDriverPath # Reinstall Chrome Web Driver +$ChromeDriverPath = "${DestinationPath}SeleniumWebDrivers\ChromeDriver"; $RegistryPath = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths" $ChromePath = (Get-ItemProperty "$RegistryPath\chrome.exe").'(default)'; [version]$ChromeVersion = [System.Diagnostics.FileVersionInfo]::GetVersionInfo($ChromePath).ProductVersion; From d9f05bf1ad7320c703faa6dc8ba3cd21b3d8e49b Mon Sep 17 00:00:00 2001 From: Dmitry Shibanov <“shibanov-1997@inbox.ru”> Date: Wed, 12 Feb 2020 22:32:42 +0300 Subject: [PATCH 12/14] add creation of directories --- .../scripts/Installers/Install-SeleniumWebDrivers.ps1 | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/images/win/scripts/Installers/Install-SeleniumWebDrivers.ps1 b/images/win/scripts/Installers/Install-SeleniumWebDrivers.ps1 index 0af2145e..6170a83e 100644 --- a/images/win/scripts/Installers/Install-SeleniumWebDrivers.ps1 +++ b/images/win/scripts/Installers/Install-SeleniumWebDrivers.ps1 @@ -20,11 +20,21 @@ Remove-Item $DriversZipFile; $SeleniumWebDriverPath = Join-Path $DestinationPath "SeleniumWebDrivers" $IEDriverPathTemp = Join-Path $TempSeleniumDir 'IEDriver' + +if (-not (Test-Path -Path $SeleniumWebDriverPath)) { + New-Item -Path $SeleniumWebDriverPath -ItemType "directory" +} + Move-Item -Path "$IEDriverPathTemp" -Destination $SeleniumWebDriverPath # Reinstall Chrome Web Driver $ChromeDriverPath = "${DestinationPath}SeleniumWebDrivers\ChromeDriver"; + +if (-not (Test-Path -Path $ChromeDriverPath)) { + New-Item -Path $ChromeDriverPath -ItemType "directory" +} + $RegistryPath = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths" $ChromePath = (Get-ItemProperty "$RegistryPath\chrome.exe").'(default)'; [version]$ChromeVersion = [System.Diagnostics.FileVersionInfo]::GetVersionInfo($ChromePath).ProductVersion; From b1d7a11c25a118776fad968598174bc5a7407085 Mon Sep 17 00:00:00 2001 From: Dmitry Shibanov <“shibanov-1997@inbox.ru”> Date: Thu, 13 Feb 2020 11:26:38 +0300 Subject: [PATCH 13/14] add GeckoWebDriver path --- images/win/scripts/Installers/Install-Firefox.ps1 | 1 + images/win/scripts/Installers/Validate-SeleniumWebDrivers.ps1 | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/images/win/scripts/Installers/Install-Firefox.ps1 b/images/win/scripts/Installers/Install-Firefox.ps1 index abf234cb..eb6cea70 100644 --- a/images/win/scripts/Installers/Install-Firefox.ps1 +++ b/images/win/scripts/Installers/Install-Firefox.ps1 @@ -61,5 +61,6 @@ Remove-Item -Path $DestFile -Force Write-Host "Setting the environment variables" Add-MachinePathItem -PathItem $FireFoxDriverPath +setx GeckoWebDriver "$FirefoxDriverPath" /M; exit 0 \ No newline at end of file diff --git a/images/win/scripts/Installers/Validate-SeleniumWebDrivers.ps1 b/images/win/scripts/Installers/Validate-SeleniumWebDrivers.ps1 index 9a68c72b..a332e69f 100644 --- a/images/win/scripts/Installers/Validate-SeleniumWebDrivers.ps1 +++ b/images/win/scripts/Installers/Validate-SeleniumWebDrivers.ps1 @@ -4,9 +4,13 @@ ################################################################################ $IEDriverPath = $env:IEWebDriver +Write-Host "IEDriverPath $IEDriverPath" $GeckoDriverPath = $env:GeckoWebDriver +Write-Host "GeckoDriverPath $GeckoDriverPath" $ChromeDriverPath = $env:ChromeWebDriver +Write-Host "ChromeDriverPath $ChromeDriverPath" $EdgeDriverPath = $env:EdgeWebDriver +Write-Host "EdgeDriverPath $EdgeDriverPath" if ( ($IEDriverPath -like "C:\SeleniumWebDrivers\IEDriver") -and From a6255415a1547a95b763ff9d2d873ff296039ee5 Mon Sep 17 00:00:00 2001 From: Dmitry Shibanov <“shibanov-1997@inbox.ru”> Date: Mon, 17 Feb 2020 14:38:52 +0300 Subject: [PATCH 14/14] minor changes --- .../scripts/Installers/Validate-SeleniumWebDrivers.ps1 | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/images/win/scripts/Installers/Validate-SeleniumWebDrivers.ps1 b/images/win/scripts/Installers/Validate-SeleniumWebDrivers.ps1 index a332e69f..e4979bd7 100644 --- a/images/win/scripts/Installers/Validate-SeleniumWebDrivers.ps1 +++ b/images/win/scripts/Installers/Validate-SeleniumWebDrivers.ps1 @@ -4,13 +4,13 @@ ################################################################################ $IEDriverPath = $env:IEWebDriver -Write-Host "IEDriverPath $IEDriverPath" +Write-Host "IEDriverPath: $IEDriverPath" $GeckoDriverPath = $env:GeckoWebDriver -Write-Host "GeckoDriverPath $GeckoDriverPath" +Write-Host "GeckoDriverPath: $GeckoDriverPath" $ChromeDriverPath = $env:ChromeWebDriver -Write-Host "ChromeDriverPath $ChromeDriverPath" +Write-Host "ChromeDriverPath: $ChromeDriverPath" $EdgeDriverPath = $env:EdgeWebDriver -Write-Host "EdgeDriverPath $EdgeDriverPath" +Write-Host "EdgeDriverPath: $EdgeDriverPath" if ( ($IEDriverPath -like "C:\SeleniumWebDrivers\IEDriver") -and