WillKuo

WillKuo

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.

0 376 0

Where Next?

Popular Macos topics Top

AstonJ
When I purchased this Mac it was fast. However some months on and it is noticeably slower now, and where I notice it most is on starting ...
14 1196 7
New
AstonJ
I’m not sure if this is a Big Sur issue or whether I’ve just noticed it, but on looking at my hard drive usage it says I have used 465.0...
5 1526 7
New
siddhant3030
I have a new MacBook Pro which I’m connecting to an external monitor. I know why it is heating but I want to know if anyone having the sa...
3 879 8
New
DevotionGeo
Since we’re talking about Mac, which of the filesystems should I use on an external hard drive (non-SSD), which I’ll be using with my Mac...
10 1106 5
New
AstonJ
Just wasted hours trying to figure out why my Apple Magic keyboard 2 started lagging after the latest macOS upgrade - tried SMC and PRAM ...
1 1035 0
New
dav
I’m searching for a tool that can (anonymously) collect crash reports from users of my macOS app (not iOS). Previously I used Fabric whic...
8 981 3
New
devovipul
I have JAR application ready. i have apple account also. Please give me steps to signed app upload i try But getting error as below : A...
2 793 1
New
leamas
Dear forum, New on macos. Need to create a .pkg file on the command line. The tooling seems to be pkgbuild(1) and productbuild(1). My pr...
3 1016 2
New
BadPistol97
I am trying to draw NSPanels on texts of other apps using AXObserverAddNotification with the attribute of kAXValueChangedNotification on ...
1 639 0
New
WillKuo
For my iOS e2e test, sometimes the test is blocked by the Mac pop-up window alert. The possible pop-up as follows: Java Access Pop-up ...
0 376 0
New

Other popular topics Top

DevotionGeo
I know that -t flag is used along with -i flag for getting an interactive shell. But I cannot digest what the man page for docker run com...
7 7340 2
New
Rainer
My first contact with Erlang was about 2 years ago when I used RabbitMQ, which is written in Erlang, for my job. This made me curious and...
195 6396 95
New
AstonJ
poll poll Be sure to check out @Dusty’s article posted here: An Introduction to Alternative Keyboard Layouts It’s one of the best write-...
10 5348 11
New
AstonJ
Do the test and post your score :nerd_face: :keyboard: If possible, please add info such as the keyboard you’re using, the layout (Qw...
82 6920 31
New
rustkas
Intensively researching Erlang books and additional resources on it, I have found that the topic of using Regular Expressions is either c...
91 5152 43
New
AstonJ
Biggest jackpot ever apparently! :upside_down_face: I don’t (usually) gamble/play the lottery, but working on a program to predict the...
19 3178 10
New
PragmaticBookshelf
Author Spotlight Jamis Buck @jamis This month, we have the pleasure of spotlighting author Jamis Buck, who has written Mazes for Prog...
21 5598 9
New
PragmaticBookshelf
Author Spotlight Rebecca Skinner @RebeccaSkinner Welcome to our latest author spotlight, where we sit down with Rebecca Skinner, auth...
106 10605 28
New
PragmaticBookshelf
Author Spotlight: Peter Ullrich @PJUllrich Data is at the core of every business, but it is useless if nobody can access and analyze ...
72 3959 21
New
PragmaticBookshelf
Author Spotlight: Bruce Tate @redrapids Programming languages always emerge out of need, and if that’s not always true, they’re defin...
54 4591 23
New