Re: How do I pause a script to allow a webpage to load and then resume the script?
Re: How do I pause a script to allow a webpage to load and then resume the script?
- Subject: Re: How do I pause a script to allow a webpage to load and then resume the script?
- From: DeNigris Sean <email@hidden>
- Date: Mon, 14 Dec 2009 11:18:00 -0500
tell application "Safari" to set docLoadingState to do _javascript_ "document.readyState" in document 1
The above will work... sometimes
I prefer either of the following techniques (add a timeout check to avoid an infinite loop)
#1: wait until whatever you need to interact with exists Example: tell application "Safari" end tell
activate application "Safari" tell application "System Events" tell process "Safari" - wait for element to exist repeat until (text field "Google Search" of group 5 of UI element 1 of scroll area 1 of group 3 of window "Google" exists) end repeat
- perform action set value of text field "Google Search" of group 5 of UI element 1 of scroll area 1 of group 3 of window "Google" to "ford" end tell end tell
#2 just keep trying to do what it is I want to do after the page loads until it's successful (actions with side effects may be an issue e.g. submitting a transaction multiple times) Example: tell application "Safari" end tell
-- keep trying to perform the action until it works repeat try activate application "Safari" tell application "System Events" tell process "Safari"
set value of text field "Google Search" of group 5 of UI element 1 of scroll area 1 of group 3 of window "Google" to "ford" click button "Google Search" of group 5 of UI element 1 of scroll area 1 of group 3 of window "Google" end tell end tell
-- continue with next step if it worked (in this case, meaning we didn't get an error) exit repeat end try end repeat end repeat
Good luck!
|
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden