From 47814c7ad7f4b7b99f300309fbb66f94982b860d Mon Sep 17 00:00:00 2001 From: Manuel Thalmann Date: Sat, 15 Jul 2023 19:47:56 +0200 Subject: [PATCH] Improve automated downloads --- scripts/Windows/Scripts/BrowserAutomation.ps1 | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/scripts/Windows/Scripts/BrowserAutomation.ps1 b/scripts/Windows/Scripts/BrowserAutomation.ps1 index bea9ca25..93a62222 100644 --- a/scripts/Windows/Scripts/BrowserAutomation.ps1 +++ b/scripts/Windows/Scripts/BrowserAutomation.ps1 @@ -16,7 +16,8 @@ function Start-AutomatedDownload() { param( [Context] $context, [string] $url, - [string] $buttonSelector + [string] $buttonSelector, + [string] $outDir = $null ) $tempDir = $context.GetTempDirectory(); @@ -58,4 +59,13 @@ function Start-AutomatedDownload() { Write-Information "Waiting for download to finish..."; Start-Sleep 1; } + + $file = Get-ChildItem $tempDir; + + if (-not $outDir) { + $outDir = "."; + } + + $result = Move-Item $file $outDir -PassThru; + return $result; }