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

Not able to clear History using applescript in El Capitan OSX

我一直在使用下面的脚本从 Yosemite OSX 中的 selenium 测试中清除 safari 历史记录。我已将 OS 升级到 El Capitan,现在脚本无法运行。

返回错误:无法获取 "Clear History" 按钮

请提供任何帮助。

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
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