Try Catch not working as expected for click Safari link

I've got a macro that runs really nicely unless I go on vacation. :wink:

It's a timesheet that I complete every Sunday. Here's the catch:

  • If I've worked as usual for the prior timesheet, it means the billing code for the new timesheet can be imported from the prior timesheet by clicking the "Import lines from previous timesheet" link. I apologize that I can't show you that link/scenario in a screenshot; I've already submitted today's timesheet so there's no way for me to make that link show up now. Be assured that it is a recognized link; that's how my macro runs most weeks of the year.
  • But if it's the week following a 0-hours week, the "Import..." link won't exist, the click action fails, and I'll need to click the "Add New Line" link instead. The "Import lines..." link would normally be listed along with this "Add New Line" link:

There's no "Link exists" condition to use with If, so I figured this was a job for Try/Catch: I Try clicking "Import lines from previous timesheet" and when that fails, the Catch sequence would click the Add New Line link, etc., to add the correct billing number explicitly.

I do have it set as described in this earlier post – the pivotal action is set to abort the macro on fail:

But it's not working for me. With these settings, the macro fails and I get no notification (also unusual).

If I change the Click Safari Link "Import lines..." action to not abort on fail but do notify, I get the same result: The macro stops and I get no notification.

FWIW, I don't have any focus modes on presently, and I am getting other notifications.

Thank you for any guidance you can provide!

I’m out running but just had a thought: I wonder if the “Add line” link includes date-specific information, such that it is unique to the “week ending” for each timesheet… I’ll check when I get home! Depending how I have the failure options set for that click action, it might be failing and (correctly) not notifying me..

The first thing I would check in troubleshooting this is that the Try Catch is working as expected. I would make a very simple test Macro to do this:

EXAMPLE Try-Catch.kmmacros (5.4 KB)

Click to Show Image of Macro

Assuming that the Try Catch does work the problem will be in what you are getting the Macro to do on the link failing.

1 Like

Will do, TY!

Whoa! This is a good one: The Web page still has an "Import lines..." link that is not shown, can be clicked by KM, and does absolutely nothing. Hilarious. So that it explains it!

Check it out:

Thanks to your suggestion and specifically those simple Display Text actions, mystery solved.
Thanks again,

1 Like