Only import selenium if existent

This commit is contained in:
Manuel Thalmann 2023-07-15 22:23:28 +02:00
parent f3b964fd87
commit 4a42abdbe4

View file

@ -2,6 +2,7 @@
. "$PSScriptRoot/Context.ps1"; . "$PSScriptRoot/Context.ps1";
if (-not ("OpenQA.Selenium.Firefox.FirefoxDriver" -as [type])) { if (-not ("OpenQA.Selenium.Firefox.FirefoxDriver" -as [type])) {
if ((Get-Package Selenium.WebDriver -ErrorAction "SilentlyContinue")) {
$zipFile = [System.IO.Compression.ZipFile]::OpenRead((Get-Package Selenium.WebDriver).Source); $zipFile = [System.IO.Compression.ZipFile]::OpenRead((Get-Package Selenium.WebDriver).Source);
$stream = [System.IO.MemoryStream]::new(); $stream = [System.IO.MemoryStream]::new();
$reader = [System.IO.StreamReader]($zipFile.Entries[2]).Open(); $reader = [System.IO.StreamReader]($zipFile.Entries[2]).Open();
@ -10,6 +11,7 @@ if (-not ("OpenQA.Selenium.Firefox.FirefoxDriver" -as [type])) {
$reader.Close(); $reader.Close();
$zipFile.Dispose(); $zipFile.Dispose();
[System.Reflection.Assembly]::Load($bytes); [System.Reflection.Assembly]::Load($bytes);
}
} }
function Start-CustomDownload() { function Start-CustomDownload() {