0

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.

kylewelsby
  • 4,031
  • 2
  • 29
  • 35
  • The **URL** on my system is: `https://music.apple.com/WebObjects/MZStore.woa/wa/viewGrouping?cc=us&id=1` That said though, I got it using **Accessibility Inspector**, because `UI element 1` in this reference its `role` is `AXWebArea` and this is a _**black box**_ to basic **AppleScript**. – user3439894 Jun 08 '20 at 16:29
  • `attribute "AXURL"` has been broken for a while, and the error message would seem to indicate that it _does_ contain data, but it can't be converted into an AppleScript type class. It's not specific to _Music_ - it's broken across the board, which also prevents evaluation of attributes collectively if they contain `AXURL` data (but the rest of the attributes can still be evaluated individually). – CJK Jun 08 '20 at 21:23
  • @CJK, RE: "(but the rest of the attributes can still be evaluated individually)." -- How? I was under the impression from things I've read that when the `role` is `AXWebArea` it's a _**black box**_ to basic **AppleScript**. – user3439894 Jun 08 '20 at 23:04
  • @user3439894 Sorry, I was referring to the general context. If the `attribute "AXURL"` exists, then other attributes do as well. But generally, as you rightly said, web areas aren't accessible in this manner as they aren't system UI components. Apologies for the confusion. – CJK Jun 10 '20 at 05:38
  • As an after thought, you could since `UI element 1` is a UI object, you can enumerate the names of other attributes and then reference those individually. I shouldn't think it'll be anything interesting though. `entire contents of UI element 1` will also reveal if there do happen to be any more UI components worthy of investigation. – CJK Jun 10 '20 at 05:41
  • Unfortunately any other elements of interest also have `AXURL` values I can not extract. The above example is simplified version. – kylewelsby Jun 10 '20 at 09:39

0 Answers0