Reliable “Wait for Safari to Load a Page” Strategies?
Let's say I have a Safari browser window open with id winID, and a tab in it with index tabIndex. I want to load a web page and get the source HTML. This seems to work (most of the time):
tell application "Safari" to tell window id winID to tell tab tabIndex
set URL to someURL
delay 30
set someHTML to source
end tell
Two problems: (1) most of the time it's unnecessarily dismally slow, and (2) it's still dangerous, if the server is really backed up it can still fail, and I may find my script reading the previous page, or possibly a partial page. It would be nice if tabs or windows had some sort of "busy" property I could test in a delay loop, but if they do I'm missing it in the dictionary. Any ideas for replacing my "delay 30" statement with something better?
Dual 1.2 GHz, Mac OS X (10.5.5)