I'm having trouble with pages not loading in Safari. This is a script that normally runs with little trouble, until lately, because Comcast seems to have slowed considerably in my area opening pages in a reasonable time. So I want to put a time limit on the page opening process. The only way I could think of to test this was by putting in a counter, and updating it once a second while testing the window name of Safari.
Here's a snippit of the code I'm using:
... other parts of script here
tell application "System Events" tell process "Safari" click UI element "Portfolio Positions" of group 19 of UI element 1 of scroll area 1 of group 3 of window "Fidelity: Portfolio" delay 3 set _page_loaded to false set _loop_count to 0 repeat until (_page_loaded or _loop_count > 179) delay 1 set _loop_count to _loop_count + 1 set _page_loaded to exists window "Fidelity: Portfolio Positions" end repeat if not _page_loaded then set the _current_time to the time string of the (current date) set _mess to _current_time & " - Portfolio Positions page not opened in 3 minutes" tell me to Message(_mess, _log) of My_Lib -- log it say _mess using "Vicki" error number -128 end if
... remainder of script
While this does work, I feel that it is rather cumbersome. Is there a better way to ensure that a page in Safari is loaded within a particular time period?
Jim Brandt
|