Automating a login on web site

Hi,

I’m new to applescript. I’m trying to automate a login on secured web site. To have access to this web site, I have to click on a button on a first page, then a second page opens where I enter my login name and my password. Here is my code:


tell application "Safari201" 
   activate 
   make new document with properties {URL:"https://www.an-net.com/WW70AWP/WW70AWP.EXE/CONNECT/annex7"} 
end tell 

delay 5 -- wait 
--until here, everything is ok
tell application "System Events" 
   click the button --here, there is a coding problem, it doesn't work   
   delay 6 --from here till the end of script, it's ok
   keystroke "login name" -- my login
   delay 3 
   keystroke tab 
   delay 2 
   keystroke "password" -- My password
   keystroke return 
end tell 

I would like to automate the click button on the first page to get access to the second page where I have to give my login and pass.
Thanks for helping me

Model: PowerMac G5 DP 2ghz
AppleScript: 2.1.1
Browser: Safari 412.5
Operating System: Mac OS X (10.4)

Try this:

do JavaScript "_T0()" in document 1 --> NOTE we have a "zero", not a capital "o"

Hi jj

I replaced «click button» by


do JavaScript "_T0()" in document 1 

like you told me. (Thanks for your suggestion)
But now, I receive an error message saying :
«Expected end of line, etc. but found identifier.» with an error number -2741
For sure, I do something wrong but I don’t know what :frowning:
Thanks for helping me

Yes, sorry. The “do JavaScript” line should be placed inside the “tell Safari” block (not the “System Events” one). :smiley:

You’re a king jj ! It works !

For everybody, here is the code :

tell application "Safari201"
	activate
	make new document with properties {URL:"https://www.an-net.com/WW70AWP/WW70AWP.EXE/CONNECT/annex7"}
	delay 6 -- wait until the page is loaded
	do JavaScript "_T0()" in document 1 
end tell

tell application "System Events"
	delay 3 -- wait until the second page is loaded
	keystroke "login name" 
	delay 3
	keystroke tab
	delay 2
	keystroke "password"
	keystroke return
end tell

Thanks a lot jj

Hi jj,

Could you tell me the meaning of « do Javascript “_T0()” » ? Is it a real javascript command ? Especially « _T0() »… I can’t succeed in finding something about it…
Thanks

_T0() is the thing executed (a JavaScript function in the HTML page) when you click the button/image. If you browse the related page using Safari, and you roll-over the “entrez/login” image, you will see in the status bar: execute script “_T0()”. So, when you click the image, this function will take care of the entrez/login action.

I can’t see it in the status bar but I can read it in the source code :