I need to "Reload" a Safari extension from the command line (and also build the package later).
How can this be done?
Why?
I'd like to build in one step - my code is in CoffeeScript and thus I'm compiling it anyway.
What have I tried?
Apart from googling hopelessly I tried using this AppleScript:
tell application "System Events"
tell process "Safari"
click the button "Reload" of window "Extension Builder"
end tell
end tell
Which errors out with:
System Events got an error: Can’t get button "Reload" of window "Extension Builder" of process "Safari".
And this variation:
tell application "System Events"
tell process "Safari"
tell button "Reload" of window "Extension Builder" to perform action
end tell
end tell
Which doesn't give an error but also doesn't actually do anything.
It may be that the button isn't "named" as you expect. Check out UI Browser in order to view an application's interface hierarchy for use with GUI scripting.
The "Reload" button is accessible with:
Extension Browser's view hierarchy seems to have changed since the accepted answer was written. This script works for me:
Note that Safari and the Extension Builder window need to be open for this to work