
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:
- 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 Mac Os topics

Hi there!
I am a new iMac user (this is the first Apple’s product for me), and I am wondering should I update the mac OS system to the n...
New

Hi there!
Do you use any “clean up” app like CleanMyMac X ?
If yes, what is those apps?
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

Combine is about to replace all those techniques for asynchronously passing information around in an iOS or macOS App: Target-Action, cal...
New

hello (also known as helloSystem ) is a desktop system for creators with focus on simplicity, elegance, and usability. Its design follows...
New

Swift for TensorFlow was an experiment in the next-generation platform for machine learning, incorporating the latest research across mac...
New

I think we need a macOS rants thread - just for those little things that bug us :face_with_symbols_over_mouth:
Feel free to start dedica...
New

New M1X chip?
10AM PDT / 6PM UK
https://twitter.com/gregjoz/status/1447956519132151810
Feed:
I hope we’ll also see an i...
New

Mac OS 9 (in your browser)
New

Generate images from text using Stable Diffusion 1.5. Simply describe the image you desire, and the app will generate it for you like mag...
New
Other popular topics

What chair do you have while working… and why?
Is there a ‘best’ type of chair or working position for developers?
New

New

No chair. I have a standing desk.
This post was split into a dedicated thread from our thread about chairs :slight_smile:
New

I’ve been hearing quite a lot of comments relating to the sound of a keyboard, with one of the most desirable of these called ‘thock’, he...
New

If you are experiencing Rails console using 100% CPU on your dev machine, then updating your development and test gems might fix the issu...
New

A Hero’s Journey
with Chris Pine
@chrispine
Chris Pine, author of Learn to Program, Third Edition, discusses his journey to beco...
New

If you want a quick and easy way to block any website on your Mac using Little Snitch simply…
File > New Rule:
And select Deny, O...
New

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

Large Language Models like ChatGPT say The Darnedest Things.
The Errors They MakeWhy We Need to Document Them, and What We Have Decided ...
New

Author Spotlight:
Sophie DeBenedetto
@SophieDeBenedetto
The days of the traditional request-response web application are long gone, b...
New
Latest in macOS
Latest (all)
Categories:
Popular Portals
- /elixir
- /rust
- /wasm
- /ruby
- /erlang
- /phoenix
- /keyboards
- /js
- /rails
- /python
- /security
- /go
- /swift
- /vim
- /clojure
- /haskell
- /java
- /emacs
- /svelte
- /onivim
- /typescript
- /crystal
- /c-plus-plus
- /tailwind
- /kotlin
- /gleam
- /react
- /flutter
- /elm
- /ocaml
- /vscode
- /opensuse
- /centos
- /ash
- /php
- /deepseek
- /zig
- /scala
- /html
- /debian
- /nixos
- /lisp
- /agda
- /textmate
- /sublime-text
- /react-native
- /kubuntu
- /arch-linux
- /revery
- /ubuntu
- /manjaro
- /spring
- /django
- /diversity
- /lua
- /nodejs
- /c
- /julia
- /slackware
- /neovim