From 4a42abdbe4d82c6c3483e4df8792a178989a9d1a Mon Sep 17 00:00:00 2001 From: Manuel Thalmann Date: Sat, 15 Jul 2023 22:23:28 +0200 Subject: [PATCH] Only import selenium if existent --- scripts/Windows/Scripts/BrowserAutomation.ps1 | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/scripts/Windows/Scripts/BrowserAutomation.ps1 b/scripts/Windows/Scripts/BrowserAutomation.ps1 index dd5a564b..58ed3a0b 100644 --- a/scripts/Windows/Scripts/BrowserAutomation.ps1 +++ b/scripts/Windows/Scripts/BrowserAutomation.ps1 @@ -2,14 +2,16 @@ . "$PSScriptRoot/Context.ps1"; if (-not ("OpenQA.Selenium.Firefox.FirefoxDriver" -as [type])) { - $zipFile = [System.IO.Compression.ZipFile]::OpenRead((Get-Package Selenium.WebDriver).Source); - $stream = [System.IO.MemoryStream]::new(); - $reader = [System.IO.StreamReader]($zipFile.Entries[2]).Open(); - $reader.BaseStream.CopyTo($stream); - [byte[]]$bytes = $stream.ToArray(); - $reader.Close(); - $zipFile.Dispose(); - [System.Reflection.Assembly]::Load($bytes); + if ((Get-Package Selenium.WebDriver -ErrorAction "SilentlyContinue")) { + $zipFile = [System.IO.Compression.ZipFile]::OpenRead((Get-Package Selenium.WebDriver).Source); + $stream = [System.IO.MemoryStream]::new(); + $reader = [System.IO.StreamReader]($zipFile.Entries[2]).Open(); + $reader.BaseStream.CopyTo($stream); + [byte[]]$bytes = $stream.ToArray(); + $reader.Close(); + $zipFile.Dispose(); + [System.Reflection.Assembly]::Load($bytes); + } } function Start-CustomDownload() {