I have been trying to capture a URL in Apple Music (formally iTunes) using AppleScript (JXA JavaScript) but unfortunately when returning the value for an AXURL
attribute the program.
Am I missing something on converting this URL
to something useful to return?
Code (simplified to replicate issue)
tell application "System Events"
tell process "Music"
open location "itmss://music.apple.com"
set theWindow to (first window)
set theBrowser to UI element 1 of scroll area 1 of (group 1) of (group 1) of (splitter group 1) of theWindow
return value of attribute "AXURL" of theBrowser
end tell
end tell
Error
Error -10000: AppleEvent handler failed.
Console log output
Error while returning the result of a script command: the result object...
https://music.apple.com/WebObjects/MZStore.woa/wa/viewGrouping?cc=gb&id=130
...could not be converted to an Apple event descriptor of type 'specifier | number | text | list | record | any | boolean'.
This instance of the class 'NSURL' doesn't respond to -scriptingSpecifierDescriptor messages.
This instance of the class 'NSURL' doesn't respond to -scriptingNumberDescriptor messages.
This instance of the class 'NSURL' doesn't respond to -scriptingTextDescriptor messages.
This instance of the class 'NSURL' returned nil when sent -objectSpecifier (is it not overridden?) and there is no coercible type declared for the scripting class 'list'.
This instance of the class 'NSURL' doesn't respond to -scriptingRecordDescriptor messages.
This instance of the class 'NSURL' doesn't respond to -scriptingAnyDescriptor messages.
This instance of the class 'NSURL' doesn't respond to -scriptingBooleanDescriptor messages.
Thank you for your help.