Allow setting a timeout for clicking download buttons
This commit is contained in:
parent
11ae127dba
commit
5a6d46153f
1 changed files with 10 additions and 2 deletions
|
@ -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!";
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue