I am trying to get the url of all opened Firefox tabs from terminal using the solution given here which describes how to do so for chrome. I tried the following:

osascript -e 'tell application "Firefox" to get URL of tab 1 of window 1'

Which is a slight modification of the following solution for Chrome:

osascript -e 'tell application "Google Chrome" to get URL of tab 1 of window 1'

However I get this error:

41:46: syntax error: A number can’t go after this property. (-2740)

Note that I have tried this for Safari and Chromium and it works for both just as it does for Google Chrome.

  • Sans very basic commands, some of the ones found in the Standard Suite dictionary, Firefox is essentially not AppleScript scriptable. Oct 22 '20 at 10:44

Don't know about all tab URLs, but since Firefox 87 you can use native AppleScript GUI scripting to get the URL of the current tab. That's because Firefox now has support for VoiceOver [1].

First enable Firefox support for VoiceOver by going to about:config and setting the accessibility.force_disabled property to -1. Note that VoiceOver doesn't have to be enabled, only the support in Firefox. (Extra info at [2].)

After that, you can use the following one liner:

osascript -e  'tell application "System Events" to get value of UI element 1 of combo box 1 of toolbar "Navigation" of first group of front window of application process "Firefox"'

Also, by iterating over the windows you could get the URLs of the frontmost tab of each window...

[1]: Enabling VoiceOver support makes Firefox expose the internal structure of its window for GUI scripting.
[2]: For extra info and a non-permanent option (toggling AXEnhancedUserInterface via AppleScript) look at this bug report.


You must log in to answer this question.

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