1

I'm trying to extract the list of cookies according to Safari.

I have the following code fragment:

tell application "Safari" to activate
tell application "System Events" to tell process "Safari"
    keystroke "," using command down -- display preferences
    delay 1
    click button "Privacy" of toolbar 1 of window 1
    delay 2 -- let the cookie count update
    click button "Details…" of group 1 of group 1 of window "Privacy"
    get <what??> of row 1 of table 1 of scroll area 1 of sheet 1 of window "Privacy"
end tell

Which is fine except that I can find no way to get the cookie name from the row. Tantalisingly, however, VoiceOver can read the value and Accessibility Inspector shows it to be held in the accessibilityLabel attribute.

Hence the question: is there a way of getting the value of the accessibilityLabel attribute in AppleScript?

Versions: Safari 9.0 / El Capitan.

PS: I know there is a Cookies.binarycookies file in the user's library. I'd still like the answer to my question for future reference at least!

0

You can access the 'description' of the 'UI Element' of each row. Like so:

tell application "Safari" to activate
tell application "System Events" to tell process "Safari"
    keystroke "," using command down -- display preferences
    delay 1
    click button "Privacy" of toolbar 1 of window 1
    delay 2 -- let the cookie count update
    click button "Details…" of group 1 of group 1 of window "Privacy"
    set z to description of UI element 1 of every row of table 1 of scroll area 1 of sheet 1 of window "Privacy"
end tell
return z
3
  • "UI element" is a helpful terminology to know about. – jweaks Oct 12 '15 at 20:52
  • Agreed. I knew about "UI element" -- it was 'description' that I didn't know about. I'm sure I tried 'value of', 'text of' and a few other optimistic guesses. Is 'UI Element' fully documented anywhere? – BruceH Oct 13 '15 at 22:07
  • A useful trick is to: set z to properties of UI element 1 of … You can then look at all the properties that might be useful. That's where I found the description property. – jweaks Oct 13 '15 at 22:25

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .