I have a script to open my web-mail on earthlink. Sometimes it works and sometimes it does not. Is there a way to make this “bullet-proof” so that it will work every time? I have this problem with lots of my scripts. Sometimes they work flawlessly and sometimes they error, quit, time-out, or just plain do nothing?
Here is the script,
tell application "Finder"
activate
open file "Steven:Applications (Mac OS 9):Netscape Communicator™ Folder:Netscape Communicator™"
tell application "Netscape Communicator™"
set winID to OpenURL "http://webmail.earthlink.net/?fn=Steven&ln=Kamm&dn=earthlink.net&mn=fruition1&zi=92677"
-- OpenURL doesn't return an integer on mine, though it should
--repeat while the busy of window -2 is 2 -- so we'll check the front window
repeat while the busy of window 1 is 2 -- so we'll check the front window
count 5
end repeat
TypeText tab
TypeText tab
TypeText "username"
TypeText tab
TypeText "password"
MouseClick At {257, 586}
MouseClick At {291, 607}
end tell
end tell
Thank you for any suggestions or solutions.
Steven.
Here’s a script to do it flawlessly in Internet Explorer 5.0. Unfortunately, I don’t know of any way to fill out forms in Netscape Communicator. Perhaps the new version >=6.0 has this?
The script is all plain vanilla AppleScript - no OSAXen.
set loginURL to "http://webmail.earthlink.net/index.php3"
tell application "Internet Explorer"
Activate
OpenURL loginURL
delay 1
repeat
try -- since it will return a non-valid response until it loads
do script "(document.documentElement.outerHTML.indexOf('</HTML>') > 0) || (document.documentElement.outerHTML.indexOf('</HTML>') > 0);"
-- check for either case of /HTML or /html, since they may change case on you
set currentLocation to result
if currentLocation is "TRUE" then exit repeat
end try
delay 1
end repeat
do script "
document.forms[0].USER.value='YOURUSERNAMEHERE';
document.forms[0].PASSWD.value='YOURPASSWORDHERE';
document.forms[0].elements[2].click();
"
-- note the single quotes - they are needed to show the name and password are
-- javascript strings. You can use double-quotes for JS strings, but then you'll
-- need to escape them
-- also, for some reason, document.forms[0].Login.click() didn't work, so I used
-- the third element in the elements array (arrays start with the 0th item in JS)
end tell