Empty Cache

This will attempt to empty Safari’s cache. From the AppleScript Users list.

OS version: OS X

tell application "Safari"
	activate
	tell application "System Events"
		tell process "Safari"
			click menu item "Empty Cache..." of menu "Safari" of menu bar 1
		end tell
	end tell
end tell

When I tried to run this script, I get the following error:

System Events got an error: NSReceiverEvaluationScriptError: 4

Model: 17" laptop
Browser: Safari 412.5
Operating System: Mac OS X (10.4)

The menu item name should be Empty Cache. with an ellipsis not Empty Cache… with three periods:

activate application "Safari"
tell application "System Events" to click menu item "Empty Cache." of menu "Safari" of menu bar 1 of process "Safari"

All menu items ending in “.” use an ellipsis (like “Preferences.”). To create an ellipsis, type option-: [colon].

Okay, thanks.

Apologies for the bump, but this method didn’t work for me, so I thought I’d post something that did.

tell application "Safari"
	activate
	tell application "System Events" to keystroke "e" using {command down, option down}
	tell application "System Events" to keystroke return
end tell

Hi.

See Qwerty Denzel’s explanation in post #3 above.

Touché.