Compare commits

...

2 commits

2 changed files with 11 additions and 3 deletions

View file

@ -127,12 +127,16 @@ $null = New-Module {
.PARAMETER OutDir
The directory to download the file to.
.PARAMETER Timeout
The number of seconds to wait before clicking the download button.
#>
function Start-BrowserDownload {
param(
[string] $URL,
[string] $ButtonSelector,
[string] $OutDir = $null
[string] $OutDir = $null,
[double] $Timeout = 0
)
Start-CustomBrowserDownload @PSBoundParameters -Action {
@ -153,8 +157,12 @@ $null = New-Module {
}
}
if ($Timeout -gt 0) {
Start-Sleep $Timeout;
}
if ($element) {
$Browser.FindElement([OpenQA.Selenium.By]::CssSelector($ButtonSelector)).Click();
$Browser.FindElement($selector).Click();
} else {
Write-Error "Unable to find download button!";
}

View file

@ -11,7 +11,7 @@ Start-SoftwareInstaller @PSBoundParameters `
-Installer {
Write-Host "Downloading reWASD…";
$dir = New-TemporaryDirectory;
$file = Start-BrowserDownload -URL "https://rewasd.com/" -ButtonSelector 'a.btn-default[href="#"]' -OutDir $dir;
$file = Start-BrowserDownload -URL "https://rewasd.com/" -ButtonSelector 'a.btn-default[href="#"]' -OutDir $dir -Timeout 1;
Write-Host "Installing reWASD…";
Start-Process -Wait -FilePath $($file.FullName) -ArgumentList "/S";