Stop "every" in AppleScript




I have an issue I am working with that would be a lot faster if there was a solution to this. I am check to see if there is a way to stop the "get value of every static text" at a certain point. Each get "static text" is a date(MM/DD/YYY). What I have been doing each individual row asking for the "static text" and if it is above/below a date. Which been time consuming since there are a lot.

Any ideas?

tell application "System Events"
   tell its application process "Safari"
      tell its window 1
         tell its splitter group 1
            tell its tab group 1
               tell its group 1
                  tell its group 1
                     tell its scroll area 1
                        tell its UI element 1
                           get value of every static text of group 1 of UI element 3 of row 2 of table 3
                        end tell
                     end tell
                  end tell
               end tell
            end tell
         end tell
      end tell
   end tell
end tell

Any help would be awesome. Alternative ideas to the above would also be welcome. Thanks! The end goal is to grab data that matches the date range from a different UI Element in the same row.


I see you are working with Safari. Is the data you want in a web page?
If so, then it would be better to use Execute a JavaScript in Browser actions to extract.

If you will provide the web page URL, or the full HTML of the web page, we can possibly help you with the JavaScript.


Hey Josh,

I concur with JM.

You don't want to use UI-Scripting in Safari unless it's the only alternative...



Thanks for the replies. Unfortunately the site is an internal site but I attempting to locate a public website that will work in a similar way.


An alternative to providing a URL is to create a WebArchive using Safari, and then zip and post that. That will contain the entire HTML of the web page, which is what we need.