Clicking a web link

Clicking a web link

Postby m2uk » Fri Jul 14, 2006 4:18 am

Hi there. I am presently evaluating this program and have came over an issue I cannot find the answer to in help or through google (or, of course, the keywords I am using are wrong).

I need to automate the clicking of a given web link (hyperlink) that is NOT presented as a "button" and the window position option is not working very well for me. However the TEXT remains constant for the hyperlink I would like to "press" in question.

Could someone kindly give me a pointer to this ? The automation I need would save me a lot of time (and eye strain, something when you have a visual problem you'd rather reduce) and it should work (I have got the program to switch to Safari and click buttons but not the hyperlinked option to progress

Thanks in advance !
m2uk
 
Posts: 23
Joined: Fri Jul 14, 2006 4:12 am

Postby gb2 » Fri Jul 14, 2006 11:20 am

give me the address of the page and what link you are trying to press and I might be able to come up with an AppleScript step to do it.
User avatar
gb2
Site Admin
 
Posts: 2870
Joined: Mon Feb 06, 2006 6:22 pm

Postby m2uk » Fri Jul 14, 2006 12:00 pm

Thanks. It is behind a log in and in Finnish :) Would it help if I a) could send a .PDF of the file, b) send a HTML file of the page or c) tell you the words of the link in question or a combination of the above.

Do you know if this "ability" could come in the future in the program as well !

Many thanks to you in advance.
m2uk
 
Posts: 23
Joined: Fri Jul 14, 2006 4:12 am

Postby gb2 » Fri Jul 14, 2006 1:37 pm

I'll send you a private message on the forum with the e-mail address to send it to.

QuicKeys already has a AppleScript step under Create>Scripting>AppleScript that you would just paste the code that I write into it.
User avatar
gb2
Site Admin
 
Posts: 2870
Joined: Mon Feb 06, 2006 6:22 pm

Postby m2uk » Fri Jul 14, 2006 1:43 pm

Thank you. I appreciate this and will send the reply very quickly.
m2uk
 
Posts: 23
Joined: Fri Jul 14, 2006 4:12 am

Postby gb2 » Fri Jul 14, 2006 4:31 pm

I think this should do it, I had some problems with the html you sent me because it was having a hard time contacting the site. I just made up a dummy page that had the elements that were needed to test it and it seemed to work. I used information from this page Link no longer available on Apple's site.

just paste in the text below into a QuicKeys AppleScript step:

Code: Select all
tell application "Safari"
       set theCount to do JavaScript "document.links.length" in document 1
       set theButtonName to "Huutokauppaa uudelleen"
   
       repeat with loopVariable from theCount - 1 to 0 by -1
              if ((do JavaScript ("document.links[" & loopVariable & "].text") in document 1) = theButtonName) then
                     set the URL of document 1 to (do JavaScript "document.links[" & loopVariable & "].href" in document 1)
                     exit repeat
              end if
       end repeat
end tell
User avatar
gb2
Site Admin
 
Posts: 2870
Joined: Mon Feb 06, 2006 6:22 pm

Postby m2uk » Sun Jul 16, 2006 11:50 am

Thank you very much. It worked. I won't pretend to be abl