Clicking buttons in Safari

Help!

I am trying to automate the user interaction with a complex (Windows) web application in Safari. I can get Safari to open the right URLs, I just can’t figure out how to tell it to click on the buttons. I’m sure there’s an easy “do JavaScript” step to do this but I don’t know what it is. Any assistance would be appreciated.

Thanks,
Craig

Browser: Safari 412.2
Operating System: Mac OS X (10.4)

I use something like this,
I think I got the syntax from a thread here some where but can not find it.

tell application "System Events"
	tell application process "Safari"
		tell application "System Events" to tell UI element "Sign In" of group 13 of group 7 of UI element 1 of scroll area 1 of group 4 of window "Login" of process "Safari" to if exists then click
		
	end tell
end tell