| external help file | Pup.dll-Help.xml |
|---|---|
| Module Name | Pup |
| online version | |
| schema | 2.0.0 |
Sets an event handler for browser-level events.
Set-PupBrowserHandler -Event <PupBrowserEvent> -ScriptBlock <ScriptBlock> [-Browser <PupBrowser>]
[-BrowserType <String>] [-ProgressAction <ActionPreference>] [<CommonParameters>]
Set-PupBrowserHandler -Event <PupBrowserEvent> -Action <PupHandlerAction> [-Browser <PupBrowser>]
[-BrowserType <String>] [-ProgressAction <ActionPreference>] [<CommonParameters>]
Registers an event handler for browser-level events like popup windows, new pages, page closures, and disconnection. Use -Action Dismiss to auto-close popups, or -ScriptBlock for custom handling.
Set-PupBrowserHandler -Browser $browser -Event PopupCreated -Action Dismiss
Automatically closes any popup windows opened by the page.
$global:popup = $null
Set-PupBrowserHandler -Browser $browser -Event PopupCreated -ScriptBlock {
param($e)
$global:popup = $e.Page
}
# Click button that opens OAuth popup
Find-PupElements -Page $page -Selector "#login-oauth" | Invoke-PupElementClick
Start-Sleep -Milliseconds 500
# Now interact with the popup
Find-PupElements -Page $global:popup -Selector "#approve" | Invoke-PupElementClick
Captures popup windows for multi-window workflows like OAuth.
$global:pages = @()
Set-PupBrowserHandler -Browser $browser -Event PageCreated -ScriptBlock {
param($e)
$global:pages += $e.Page
Write-Host "New page opened: $($e.Page.Url)"
}
Tracks all new pages/tabs opened in the browser.
Action to take when the event occurs (Dismiss for popups)
Type: PupHandlerAction
Parameter Sets: Action
Aliases:
Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: FalseThe browser instance
Type: PupBrowser
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: True (ByPropertyName, ByValue)
Accept wildcard characters: FalseName of the browser to stop (used when Browser parameter is not provided)
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: FalseThe browser event to handle
Type: PupBrowserEvent
Parameter Sets: (All)
Aliases:
Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False{{ Fill ProgressAction Description }}
Type: ActionPreference
Parameter Sets: (All)
Aliases: proga
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: FalseScript block to execute when the event occurs. Receives event data as parameter.
Type: ScriptBlock
Parameter Sets: ScriptBlock
Aliases:
Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: FalseThis cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.