tell application "System Events"
tell process "Finder"
set frontmost to true
click menu item "Go to Folder." of menu "Go" of menu bar 1
end tell
end tell
Trying to do this:
tell application "System Events"
tell process "Finder"
set frontmost to true
click menu item "Go to Folder." of menu "Go" of menu bar 1
set value of text field 1 to "~/Library/Favorites/"
click menu button "Go"
end tell
end tell
Continuing on the path you were taking, you’d need to identify the full hierarchy of the text field and button (i.e., text field 1 of window 1, etc.). However, since this window is modal, the text field is the first responder, and the button is the default button, you can simply use the keystroke command to type the text and then hit return:
tell application "System Events"
tell process "Finder"
set frontmost to true
click menu item "Go to Folder." of menu "Go" of menu bar 1
keystroke "~/Library/Favorites/"
keystroke return
end tell
end tell
That said, an even easier way (and vastly more desirable than using GUI scripting) is to just script the Finder directly:
tell application "Finder"
activate
open (path to favorites folder)
end tell