0 Replies
      Latest reply on Jan 4, 2020 2:32 PM by macfan
      macfan Level 1 Level 1 (0 points)

        Hi there... Im looking for help getting a small Script Editor app to function properly.

         

        This app simply opens Safari and then clicks the "Clear History..." button so that each new session is started with a freshly cleaned browser.

        This action can be done manually but it is much quicker when using the script to do it.

         

        I've also made the same basic script to clear Safari and then quit Safari.

         

        Script Editor was used to make the script then save it as an application in the user  Application folder.

        It was given Accessibility permissions and set up as a Service with a command key assigned to activate it.

        ========

         

        Here is the issue that I'm stumbling upon.

         

        When I manually go trough the menus and select the Clear History button it actually does it.

        The History, the website data and the cookies and who knows what else are all cleared out as expected and I'm left with a fresh browser to use.

         

        But when the Script Editor script is used ... to click the exact same button, ....only the History is cleared. The website data and cookies and who knows what else are not cleared and are still present the next time Safari is used.

         

        I have very limited expeience with Automator and Script Editor and app making and my guess is that my little app that could is stumbling into a Sandboxing issue?? but I really do not have a clue why manually clicking a button is different than getting a script to click the exact same button.

         

        I thank you in advance for your time and efforts at looking at this.

        Here is the open and clear Safari script...

         

        tell application "System Events"
          tell application "Safari"
          activate
          close every window
          end tell
        
          tell application "System Events" to tell process "Safari"
          click last menu item of menu "History" of menu bar 1
          delay 1.0E-3
          click button "Clear History" of window 1
          delay 1.0E-3
          click first menu item of menu "File" of menu bar 1
          end tell
        
        end tell

         

         

        and here is the opposite clear then close Safari script

        tell application "System Events"
          tell application "Safari"
          close every window
          end tell
        
          tell application "System Events" to tell process "Safari"
          click last menu item of menu "History" of menu bar 1
          delay 1.0E-3
          set frontmost to true
          delay 1.0E-3
          click button "Clear History" of window 1
          end tell
          tell application "Safari"
          quit
          end tell
        end tell