无法在El Capitan OSX中使用AppleScript清除历史记录

时间:2016-09-11 01:31:39

标签: applescript osx-elcapitan

我一直在使用以下脚本来清除Yosemite OSX中硒测试的野生动物历史。我已将操作系统升级到El Capitan,现在脚本无法正常工作。

返回错误:无法获取“清除历史记录”按钮

对此有任何帮助。

tell application "Safari" to activate
 tell application "System Events"
  tell process "Safari"
    tell menu bar 1
        tell menu bar item "History"
            tell menu 1
                click menu item "Clear History…"
            end tell
        end tell
    end tell
    delay 1 -- optional
    click button "Clear History"
  end tell
end tell

1 个答案:

答案 0 :(得分:-1)

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