Apple Script for opening safari and this will you know the status that page is completely loaded.

ANKIT BANSAL
1 min readAug 18, 2018

--

AppleScript is a scripting language created by Apple Inc. that facilitates automated control over scriptable Mac applications.
AppleScript is a language used to automate the actions of the Macintosh Operating System and many of its applications.

We need to use Script Editor in MAC to write the Apple Script.

Script :

tell application “Safari” to open location “https://medium.com/@ankitbansal806"

say “loaded”

display dialog “Loaded”

else

say “failed”

display dialog “failed”

end if

on page_loaded(timeout_value) — in seconds

delay 1

repeat with i from 1 to timeout_value

tell application “Safari”

if name of current tab of window 1 is not “Loading” then exit repeat

end tell

delay 1

end repeat

if i is timeout_value then return false

tell application “Safari”

repeat until (do JavaScript “document.readyState” in document 1) is “complete”

delay 0.5

end repeat

end tell

return true

end page_loaded

Note : Before run this script you need to allow the Java Script apple events in Safari’s develop menu.

--

--

ANKIT BANSAL

I devise, design and develop well-crafted interactive iOS and Android apps. Cocoa & Swift adventures. Working @Accenture Ex. @thinkfuturetech