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:
- Java Access Pop-up
- Accessibility Pop-up
- SystemProperty Pop-up
- and so on…
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.
Popular Macos topics

Anyone going to be upgrading anytime soon? :upside_down_face:
New

New

Hi there!
I recently bought a new mouse pad (HyperX Fury) and it feels like without mouse pad the magic mouse is working better(smoother...
New
New

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...
New

Intel clearly not happy that Apple are now creating their own silicon :081:
New

WeatherKit - Apple Developer.
WeatherKit brings valuable weather information to your apps and services through a wide range of data that...
New

Mac OS 9 (in your browser)
New

I caught bits of it, so gonna catch up now - what did you think?
New

Hello, Apple developers!
I want to upload an app to testflight, but I’m having the issue from the picture and I can’t get around it.
Ha...
New
Other popular topics

Any thoughts on Svelte?
Svelte is a radical new approach to building user interfaces. Whereas traditional frameworks like React and Vue...
New

Bought the Moonlander mechanical keyboard. Cherry Brown MX switches. Arms and wrists have been hurting enough that it’s time I did someth...
New

On modern versions of macOS, you simply can’t power on your computer, launch a text editor or eBook reader, and write or read, without a ...
New

Inspired by this post from @Carter, which languages, frameworks or other tech or tools do you think is killing it right now? :upside_down...
New

Continuing the discussion from Thinking about learning Crystal, let’s discuss - I was wondering which languages don’t GC - maybe we can c...
New

Woooooooo! This is such a huge release for it, and 2 years incoming!
In short, the library is now using an updated hyper backend (not j...
New

Saw this on TikTok of all places! :lol:
Anyone heard of them before?
Lite:
New

Inside our android webview app, we are trying to paste the copied content from another app eg (notes) using navigator.clipboard.readtext ...
New

Author Spotlight: Karl Stolley (@karlstolley)
Logic! Rhetoric! Prag! Wow, what a combination. In this spotlight, we sit down with Kar...
New

Author Spotlight: Tammy Coron (@Paradox927)
Gaming, and writing games in particular, is about passion, vision, experience, and immers...
New
Latest in Macos
Latest (all)
Categories:
My Saved Portals
-
None saved yet
Popular Portals
- /elixir
- /opensuse
- /rust
- /kotlin
- /ruby
- /erlang
- /python
- /clojure
- /react
- /quarkus
- /go
- /vapor
- /v
- /react-native
- /wasm
- /security
- /django
- /nodejs
- /centos
- /haskell
- /rails
- /fable
- /gleam
- /swift
- /js
- /deno
- /assemblyscript
- /tailwind
- /laravel
- /symfony
- /phoenix
- /crystal
- /typescript
- /debian
- /adonisjs
- /julia
- /arch-linux
- /svelte
- /spring
- /c-plus-plus
- /flutter
- /preact
- /actix
- /java
- /angular
- /ocaml
- /zig
- /kubuntu
- /scala
- /zotonic
- /vim
- /rocky
- /lisp
- /html
- /keyboards
- /vuejs
- /nim
- /emacs
- /nerves
- /elm