1

Background: My goal here is to gather connection speed data that my ISP will accept so I can demonstrate dramatic drops in connection speed lasting 1-5 minutes that I've been experiencing immediately after switching to this new ISP (same equipment - with no prior such speed inconsistencies). They only accept (and can access) connection speed test results by using their speed test website when run from a wired computer (i.e. not one connected via Wifi).

So I created a quick little automator workflow that generally works... unless the connection speed drops out and the website doesn't respond - which thwarts my entire goal!

I had initially recorded the following initial actions in a watch-me-do:

  1. Click Safari in the dock
  2. Click a bookmarks folder
  3. Click the bookmark for the speed test website
  4. Click the speed test start button

which is followed by processing of the results that generally works and is fault tolerant. However, there are 2 things that can happen which lead to a fatal error in the workflow:

  1. The web page doesn't load
  2. The web page loads but the speed test start button doesn't load (the page initially shows a loading graphic where the button will appear)

I am fine with the occasional test failing. I have code that parses the text on the page and such results show up in the log as a test failure with a timestamp.

However, the script issues an error when it can't click the button and all further testing stops, so I tried dragging the button-click action from the watch-me-do into the workflow, which becomes an editable applescript. I figured I could edit the script to change the error call inside the on error block. The resulting workaround sort of works, but now it appears that it NEVER thinks the button is getting successfully clicked and eventually hits the time-out, goes into on error, and runs the line I added: exit repeat.

So what is going on here? Why does the script appear to not detect that the click action was performed successfully?

Here's the code from the button click action dragged from the watch-me-do:

on run {input, parameters}
    -- Click the “Start” button.
    tell application "Safari" to activate  --I added this line
    delay 6.095782
    set timeoutSeconds to 2.0
    set uiScript to "click UI Element \"Start\" of group 1 of group 2 of UI Element 1 of scroll area 1 of group 1 of group 1 of tab group 1 of splitter group 1 of window \"Speed Test\" of application process \"Safari\""
    my doWithTimeout(uiScript, timeoutSeconds)
    return input
end run

on doWithTimeout(uiScript, timeoutSeconds)
    set endDate to (current date) + timeoutSeconds
    repeat
        try
            run script "tell application \"System Events\"
" & uiScript & "
end tell"
            exit repeat
        on error errorMessage
            if ((current date) > endDate) then
                exit repeat  --I replaced an error call here
            end if
        end try
    end repeat
end doWithTimeout
  • I redacted ISP particulars (see comments below).
  • TLDR. What's the website URL for the speed test ? – CJK Oct 19 '18 at 15:54
  • 1
    Well, I didn't want to reveal the ISP for 2 reasons. 1. They appear to have gone to come effort to prevent scripting of their webpage, so I didn't want them to find this post and try to thwart my script. 2. I didn't want to publicly malign this ISP for poor consistency before I was able to show it with my test results. I'm not using one of their supported routers, so it's possible the issue is due to an incompatibility. That's why my question is about clicking a bookmark instead of clicking their start test button. – hepcat72 Oct 19 '18 at 16:08
  • And sorry about the question length. Succinctness is not one of my strong suits. – hepcat72 Oct 19 '18 at 16:09
  • You just want to click the bookmark in Safari ? – CJK Oct 19 '18 at 16:11
  • 1
    Perhaps the behaviour seems similar, but the solutions are different. For one, you don't need to click on the Safari bookmark to take you to the webpage. AppleScript can take you there by itself, by controlling Safari directly. Would that be useful if I showed you how to do that ? – CJK Oct 19 '18 at 16:23

You must log in to answer this question.

Browse other questions tagged .