Accessing dock icon right-click menu items with AppleScript
Not sure if you are still interested but...
tell application "Dock"
activate
end tell
tell application "System Events"
tell process "Dock"
set frontmost to true
activate
tell list 1
perform action "AXShowMenu" of UI element "Google Chrome"
delay 1
repeat 4 times -- count number of items to the one you want
key code 126 -- up arrow
-- key code 125 -- down arrow
end repeat
delay 1
repeat 2 times
key code 36 -- return key
end repeat
end tell
end tell
end tell
As a variation to the most upvoted answer, here's a version of the script that accepts the name of the menu item, which lets you avoid having to do any counting.
This example clicks "Go to Folder..." from Finder's dock menu.
tell application "Dock"
activate
end tell
tell application "System Events"
tell process "Dock"
set frontmost to true
activate
tell UI element "Finder" of list 1
perform action "AXShowMenu"
click menu item "Go to Folder…" of menu "Finder"
end tell
end tell
end tell