Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion Tools/windows/Invoke-UiCaptureWorker.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -495,18 +495,28 @@ function Wait-CapVisibleElement {
)
Write-CapTrace -Command $MyInvocation.MyCommand.Name -Parameters $PSBoundParameters

$lastSnapshot = $null
$lastPollUtc = $null
try {
while ([DateTime]::UtcNow -lt $leaseDeadlineUtc) {
Assert-CapWorkerDeadline "UIA element $Name"
$lastPollUtc = [DateTime]::UtcNow
try {
return Find-CapAutomationElement -RootHandle $Window -ProcessIdentity $ProcessIdentity `
-Name $Name -AutomationId $AutomationId -AutomationIdPrefix $AutomationIdPrefix `
-AllowOffscreen:$AllowOffscreen
-AllowOffscreen:$AllowOffscreen -RefusalSnapshot ([ref]$lastSnapshot)
} catch {
if ($_.Exception.Message -notmatch 'found=0\.') { throw }
Start-Sleep -Milliseconds 100
}
}
throw "UIA element '$Name' did not become available before the reserved deadline."
} catch {
Write-CapTerminalSelectorRefusal -Snapshot $lastSnapshot -Refusal $_ -PollUtc $lastPollUtc `
-DeadlineUtc $leaseDeadlineUtc -Window $Window -ProcessIdentity $ProcessIdentity `
-Name $Name -AutomationId $AutomationId -AutomationIdPrefix $AutomationIdPrefix -AllowOffscreen:$AllowOffscreen
throw
}
}

function Invoke-CapSceneAction {
Expand Down
Loading
Loading