Netscape Script

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"
open file "Steven:Applications (Mac OS 9):Netscape Communicator™ Folder:Netscape Communicator™"
tell application "Netscape Communicator™"
set winID to OpenURL ""
-- 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.

Precise the addition that you’re using (Sandi’s addition or Sigma addition, both have the Type Text command)

Just out of curiousity: if you have both, which takes precedence?

tet, I don’t know because i disabled one of them, because they are doing quite the same thing Jean-baptiste LE STANG

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 ""
tell application "Internet Explorer"
OpenURL loginURL
delay 1
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 "
-- 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] didn't work, so I used
-- the third element in the elements array (arrays start with the 0th item in JS)
end tell