Refactor function for waiting for download

This commit is contained in:
Manuel Thalmann 2023-07-15 19:37:30 +02:00
parent 164430e9b4
commit 7db3d35e86

View file

@ -28,6 +28,9 @@ function Start-AutomatedDownload() {
$downloadChecker = { $downloadChecker = {
param() param()
$files = Get-ChildItem $tempDir;
if ($(@($files)).Count -ge 0) {
foreach ($file in Get-ChildItem $tempDir) { foreach ($file in Get-ChildItem $tempDir) {
try { try {
$stream = [System.IO.File]::Open($file.FullName, [System.IO.FileMode]::Open, [System.IO.FileAccess]::ReadWrite, [System.IO.FileShare]::None); $stream = [System.IO.File]::Open($file.FullName, [System.IO.FileMode]::Open, [System.IO.FileAccess]::ReadWrite, [System.IO.FileShare]::None);
@ -42,6 +45,9 @@ function Start-AutomatedDownload() {
return $true; return $true;
} }
} }
} else {
return $false;
}
} }
$browser = [OpenQA.Selenium.Firefox.FirefoxDriver]::new($options); $browser = [OpenQA.Selenium.Firefox.FirefoxDriver]::new($options);