Using control flow to navigate web pages


I have a workflow that clicks on a ‘log in’ link and then logs me in. It then goes and does a bunch of other great stuff. The problem is that if I’m already logged in, the whole workflow fails.

I haven’t used control flow much, but I’m figuring this could be done with a if then else action, but I can’t find the condition that would allow me to say ‘if this element is on the page’ then ----- else.

Any ideas?

Hey Damian,

The two options that come to mind are:

A) Use a JavaScript action to return the text or HTML of the element you’re looking for, and set a Keyboard Maestro variable to the result. You could preset the variable “false” and test against that.

B) Parse the entire source of the given web page for what you need.

If you’re using Safari or Chrome then these should be possible.


1 Like

A third option is to unilaterally log out first. If that fails (because you are already logged out) it doesn’t matter.

If the normal state is logged out, or the macro is run relatively rarely that the extra time required to log out is not a problem, this can be a quick fix.

1 Like