Can't Figure Out "If This Then That"

I have no idea what I'm doing when it comes to programming, HTML, Keyboard Maestro, or anything of the sort, so I don't know what half the vocabulary means. I'm creating a macro to try to automate a tedious task I'm doing at work right now (I'm on a Mac if that matters), but I'm stuck on one part of it. Basically I need the macro to check if there's a word on the page (Chrome browser page) that says "Delete" (it's a blue clickable button or hyperlink I guess), and if so, to press that button.

Right now I have the macro set up so it does the following:

  • Move and Click mouse at certain point (on a text field, which is above the delete button)
  • Type the Tab Keystroke
  • Type the Tab Keystroke (these are to get the page to highlight the Delete button, if it exists)

and from there I can't figure out how to make it do something like "If highlighted text says Delete, press enter/return". I've tried so many different options of If Then, but can't find one that works. The problem is if the Delete button doesn't exist, having it press Tab twice will highlight a different button altogether that I don't want it to press.

Hopefully this made some sort of sense to you guys and someone is able to help. Thanks in advance!

Can you share what you have done so far.

You can use a
If: Found Image condition,
And place a screenshot of the Delete button in there.

Hey Adam,

Welcome to the forum!   :smile:

To click a button on a web page you need to use JavaScript, because those elements are rendered HTML in a web browser and not macOS application button objects.

Use the “Google Chrome” or “Front Browser” options.

(This is the Insert Action by Name dialog.)

Use either XPath or Query Selector in JavaScript to click the button.

Chrome's Developer Tools are your friend in cases like this.

If you can post the page, we can help you with the code.

-Chris

1 Like

Yesssss that worked perfectly, thank you so much! I hadn't tried this at first cause I didn't think the text counted as an "image".

@ccstone that just made me realize I also know nothing about JavaScript or how to use Chrome's Developer Tools haha. Thanks for the help and the warm welcome!

1 Like