Re: How Can One Tell When Safari Completes?
Re: How Can One Tell When Safari Completes?
- Subject: Re: How Can One Tell When Safari Completes?
- From: Gil Dawson via AppleScript-Users <email@hidden>
- Date: Tue, 11 Feb 2025 18:23:06 -0800
Thanks, Deivy--
Good point.
I had planned to adjust the timeout after some experience. Waiting forever for
Safari to give up does now seem a better choice.
Also, my code checks afterward that the document has the proper domain URL, in
order to detect major upload issues. Checking the URL will fail with sites
that auto-redirect. In case of failure, Safari posts an error message to the
window, but I don't see how to get at it in AppleScript.
Thanks for your comment.
--Gil
> On Feb 11, 2025, at 10:37 AM, Deivy Petrescu <email@hidden> wrote:
>
>
>
>> On Feb 11, 2025, at 12:43 PM, Gil Dawson via AppleScript-Users
>> <email@hidden> wrote:
>>
>> set SecondsToWait to 30 -- Number of seconds to wait on Safari
>> tell application "Safari"
>> quit --set up for the test
>> delay 3 -- wait until almost certainly quiescent for the test
>>
>> activate
>> open location "https://www.disney.com" --begin test
>> repeat SecondsToWait * 2 times
>> delay 0.5 -- Add a small delay for Safari to update its status
>> set ReadyState to do JavaScript "document.readyState" in document 1
>> log "ReadyState=" & ReadyState
>> if ReadyState is "complete" then exit repeat
>> end repeat
>> end tell
>>
>
> In your case, if there is any issue with uploading the page, for instance
> taking a minute or more, you will leave the loop before the page is loaded.
> This is the case because you set your loop to run a fixed number of cycles.
> I’d modify the loop in the script to:
>
>
>
> <script>
> ...
> set ReadyState to ""
> repeat while ReadyState is not "complete"
> set ReadyState to do JavaScript "document.readyState" in document 1
> log "ReadyState=" & ReadyState
> end repeat
> End tell
> </script>
>
>
> Best, be safe.
>
> Deivy Petrescu
> email@hidden
>
>
>
>
>
>
_______________________________________________
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