From http://www.cubemg.com/how-to-click-a-button-on-a-web-page-with-applescript/
to clickName(theName, elementnum) tell application "Safari" do JavaScript "document.getElementsByName('" & theName & "')[" & elementnum & "].click();" in document 1 end tell end clickName