Refactor browser scripts
This commit is contained in:
parent
29b0de86dc
commit
b92173fa25
2 changed files with 5 additions and 3 deletions
|
@ -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…";
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue