Trying to access Safari developer tools prints "Access not allowed (-1723)"
I am trying to create a script which lists me all available open simulators to inspect in safari developer tools but when I run the code I get the below error. At the end this script should open the inspector tool for one simulator device. My guess it that in general this is not allowed but I gave the terminal the accessibility rights so yeah I have no idea.
listDevices.applescript:122:168: script error: „"Simulator" of menu "Entwickler" of menu bar 1“ kann nicht gelesen werden. Zugriff nicht erlaubt. (-1723)
tell application "System Events"
tell process "Safari"
name of every menu item of menu item where its name starts with "Simulator" of menu "Entwickler" of menu bar 1
end tell
end tell
Solution 1:
I do not have a menu item that starts with Simulator; however, using Experimental as in Experimental Features, the following example AppleScript code did retrieve the names of the menu items on the Experimental Features menu item of the Develop menu in Safari. (My system is set to US English.)
tell application "System Events" to tell application process "Safari"
set menuItemNames to get name of every menu item of menu 1 of ¬
(first menu item whose name starts with "Experimental") of ¬
menu 1 of menu bar item "Develop" of menu bar 1
end tell
return menuItemNames
So if you change "Experimental"
to "Simulator"
and "Develop"
to "Entwickler"
I'd imagine it would work for you.