: tell application "Safari" to close every window .
: The do JavaScript command allows you to interact with the DOM, such as getting a page title or clicking buttons. applescript safari s
For more complex tasks like form filling, scripts often combine AppleScript with JavaScript: Working in a Safari Browser - AppleScript | Mac OS X : tell application "Safari" to close every window
: You can reference specific tabs to get properties like their index or to switch focus. applescript safari s