Improve handling of slow websites

This commit is contained in:
Manuel Thalmann 2024-08-14 18:47:29 +02:00
parent fab0da1d65
commit 51f352f095

View file

@ -90,6 +90,8 @@ $null = New-Module {
$browser = [OpenQA.Selenium.Firefox.FirefoxDriver]::new($options);
$browser.Navigate().GoToUrl($URL);
try {
$null = & $downloadAction -Browser $browser;
while (& $downloadChecker) {
@ -103,6 +105,10 @@ $null = New-Module {
Remove-Item -Recurse $dir;
$result;
}
catch {
throw $Error;
}
}
}
<#
@ -130,7 +136,24 @@ $null = New-Module {
[OpenQA.Selenium.Firefox.FirefoxDriver] $Browser
)
$selector = [OpenQA.Selenium.By]::CssSelector($ButtonSelector);
[OpenQA.Selenium.IWebElement] $element = $null;
for ($i = 0; $i -lt 5; $i++) {
$element = $Browser.FindElement($selector);
if ($element) {
break;
} else {
Start-Sleep 1;
}
}
if ($element) {
$Browser.FindElement([OpenQA.Selenium.By]::CssSelector($ButtonSelector)).Click();
} else {
throw "Unable to find download button!";
}
};
}
};