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:
- Click Safari in the dock
- Click a bookmarks folder
- Click the bookmark for the speed test website
- 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:
- The web page doesn't load
- 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).