How to capture the popup window information in the Mac desktop by Apple Script?

For my iOS e2e test, sometimes the test is blocked by the Mac pop-up window alert. The possible pop-up as follows:

In order to fetch the unexpected pop-up dialog window when executing e2e tests. I write a simple Apple script get_popup_windows.scpt as follows:

tell application "System Events"
    set allProcesses to processes whose background only is false

    -- Log the count of allProcesses
    log "Number of processes found: " & (count of allProcesses)

    set dialogInfos to {}

    repeat with eachProcess in allProcesses
        try
            tell eachProcess
                log "Process Name: " & (name of eachProcess as text)
                set allWindows to (windows whose subrole is "AXStandardWindow" or subrole is "AXDialog")
                log "Number of allWindows found: " & (count of allWindows)
                repeat with eachWindow in allWindows
                    set uiElements to UI elements of eachWindow
                    log "eachWindow: " & (name of eachWindow as text)
                    set the end of dialogInfos to {title:(name of eachWindow as text), processName:(name of eachProcess as text)}
                end repeat
            end tell
        end try
    end repeat
end tell

return dialogInfos

However, when I execute the script: osascript get_popup_windows.scpt The result as follows:

Number of processes found: 10
Process Name: Terminal
Number of allWindows found: 1
eachWindow: scripts — osascript get_popup_windows.scpt — 143×41
Process Name: Google Chrome
Number of allWindows found: 1
eachWindow: Gemini - Google Chrome - Will
Process Name: sublime_text
Number of allWindows found: 0
Process Name: Notes
Number of allWindows found: 0
Process Name: Music
Number of allWindows found: 0
Process Name: Finder
Number of allWindows found: 0
Process Name: app_mode_loader
Number of allWindows found: 0
Process Name: Simulator
Number of allWindows found: 0
Process Name: app_mode_loader
Number of allWindows found: 0
Process Name: Script Editor
Number of allWindows found: 0
title:scripts — osascript get_popup_windows.scpt — 143×41, processName:Terminal, title:Gemini - Google Chrome - Will, processName:Google Chrome

=> I cannot fetch the target pop-up window in the Mac desktop. Please guide me if you have any suggestions, thanks.