需要applescript在MAC上为Safari 8浏览器提供clear cookie

需要applescript在MAC上为Safari 8浏览器提供clear cookie,applescript,Applescript,我需要使用applescript执行以下操作 发射狩猎 单击Safari菜单栏上的“清除历史记录和网站数据” 点击“清除历史记录”按钮 关闭safari浏览器 我已尝试使用以下代码: tell application "Safari" to activate tell application "System Events" click menu item "Clear History and Website Data…" of menu "Safari" of menu bar ite

我需要使用applescript执行以下操作

  • 发射狩猎
  • 单击Safari菜单栏上的“清除历史记录和网站数据”
  • 点击“清除历史记录”按钮
  • 关闭safari浏览器
我已尝试使用以下代码:

tell application "Safari" to activate 
tell application "System Events"
  click menu item "Clear History and Website Data…" of menu "Safari" of menu bar item "Safari" of menu bar 1 of application process "Safari"
  delay 1
  click button "Clear History" of pop up "Safari"
  quit
end tell

看起来根本不像代码。此代码有什么问题?请尽可能完整和准确。问题无法单击“清除历史记录”按钮,步骤出错:单击弹出窗口“Safari”的“清除历史记录”按钮Safari 8清除cookies应用程序请参阅此屏幕截图脚本:
tell application "Safari" to activate  
set frontmost to true  
tell application "System Events"  
    tell process "Safari"  
        set frontmost to true  
        click menu item "Clear History…" of menu "History" of menu bar 1  
        delay 3  
        click button "Clear History" of sheet 1 of window 1  
    end tell  
end tell  
tell application "Safari" to quit