How to click on javascript link in safari

How can I click on a javascript link using applescript. This a example of the javascript link:

Ver Resultados

Here is where the javascript example is located:

I will appreciate you help.


something like this

tell application "Safari"
	open location ""
	if my page_loaded(20) is false then return
	do JavaScript "VerEncuesta('4353','N');" in document 1
end tell

on page_loaded(timeout_value)
	delay 2
	repeat with i from 1 to the timeout_value
		tell application "Safari"
			if (do JavaScript "document.readyState" in document 1) is "complete" then
				return true
			else if i is the timeout_value then
				return false
				delay 1
			end if
		end tell
	end repeat
	return false
end page_loaded


I’m trying to do almost the same thing as are posted here, but this solution didn’t worked!

I figured out that I can’t use:

open location (do JavaScript “MultiSelectPicklist.handleMSPSelect%28%2700N70000001w9i1%27%29%3B” in document 1)

the problem is in the “open location”… what is the right command here?

I tried too:

do JavaScript “document.links[41].click” in document 1 or
do JavaScript “document.links[41].click()”

but didn’t work as well…

Does Anyone else have any idea?

in my case, this is the source code:


Thanks for any help!