From b92173fa258004f41ba8f33f956f41e2423b3d21 Mon Sep 17 00:00:00 2001 From: Manuel Thalmann Date: Thu, 8 Aug 2024 03:32:03 +0200 Subject: [PATCH] Refactor browser scripts --- scripts/Common/Scripts/BrowserAutomation.ps1 | 4 +++- scripts/Common/Scripts/Software.ps1 | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/scripts/Common/Scripts/BrowserAutomation.ps1 b/scripts/Common/Scripts/BrowserAutomation.ps1 index b51a1901..1fc815fa 100644 --- a/scripts/Common/Scripts/BrowserAutomation.ps1 +++ b/scripts/Common/Scripts/BrowserAutomation.ps1 @@ -52,6 +52,8 @@ $null = New-Module { [string] $OutDir ) + $downloadAction = $Action; + Start-BrowserAutomation { if (-not $OutDir) { $OutDir = "."; @@ -88,7 +90,7 @@ $null = New-Module { $browser = [OpenQA.Selenium.Firefox.FirefoxDriver]::new($options); $browser.Navigate().GoToUrl($URL); - & $Action -Browser $browser; + $null = & $downloadAction -Browser $browser; while (& $downloadChecker) { Write-Host "Waiting for the download to finish…"; diff --git a/scripts/Common/Scripts/Software.ps1 b/scripts/Common/Scripts/Software.ps1 index 136cca04..5cbeb41d 100644 --- a/scripts/Common/Scripts/Software.ps1 +++ b/scripts/Common/Scripts/Software.ps1 @@ -134,12 +134,12 @@ $null = New-Module { try { & $download; } catch { - $Browser.ExecuteScript("document.querySelector('$cookieBannerSelector').remove()"); + $null = $Browser.ExecuteScript("document.querySelector('$cookieBannerSelector').remove()"); & $download; } }; - Start-Process -Wait -WorkingDirectory $dir -FilePath $file -ArgumentList "/S"; + Start-Process -Wait -WorkingDirectory (Split-Path -Parent "$file") -FilePath "$file" -ArgumentList "/S"; Remove-Item -Recurse $dir; }