Hello,
I’m trying to automate Catalyst/iOS apps running on the new Apple Silicon Macs. I am observing an extremely odd behavior — if I use Automator to record a script and then I play it, all works fine. But if I export this script to AppleScript and run in there or using osascript, I get an error on the first element that its path is invalid. I tried the trusty UI Explorer and it shows the same path as Automator! Strangely though, if I do some tedious debugging using “entire contents”, I find out that in AppleScript/osascript, the same element is nested within 7-8 more elements!
AppleScript coming from Automator/UI Explorer, does not work in AppleScript/osascript:
tell application "System Events"
click text field 1 of group 1 of group 2 of group 1 of group 1 of window 1 of application process "TestApp"
end tell
AppleScript through guesswork and “entire contents”, actually works in AppleScript/osascript:
tell application "System Events"
click text field 1 of group 1 of group 2 of group 1 of scroll area 1 of group 1 of group 1 of group 2 of group 1 of group 2 of group 1 of group 1 of window 1 of application process "TestApp"
end tell
This behavior makes it extremely tedious, if not impossible, to automate the UI. Would you have any clue why this is happening?
Thanks a lot!