From e63c3251d857a62f8cb6eacd920a17a70db593e8 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 5fcb02d4..a7192153 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 88860230..685547c6 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; }