Click item on Chrome or Safari page by XPath

I am not sure what I am missing but I can’t import this macro to KM. I unzip it and get some files but how do I get it to work within KM? :expressionless:

Hey Nikita,

That’s not macro — it’s a plug-in.

Drag the whole zip file to the Keyboard Maestro Editor icon in the Dock.


I cannot get it to work!
version: keyboardmaestro 8.0.3

Task failed with status 1 in macro "Plug
In" (while executing Click Google Chrome item matching XPath applied to mouse position ).

I don’t know what the plugin is doing, but you can use XPath with the built in Click Browser Link action in Keyboard Maestro 8.


thank you very much

Is this plugin still functional in KM 8.0.5? I’ve installed it and pasted an xPath. I’ve tried all the “applied” option, without success. Wondering if I’m wasting my time. I tried the “Click Browser Link” action but it did not work. The named button I’m trying to click does not appear in the “list” and entering the name does not work.

I am trying to reduce my dependance on clicking at “found images”.

Can you show us the page and button, and the XPath that you are trying to reference it with ?

In the meanwhile, to obtain a valid XPath reference to a clickable element ( e.g. an <a> or <button> element in the HTML) :

  1. In Chrome (better equipped with XPath capture tools than Safari, even if it is Safari that you will target)
    ctrl-click the element of interest, and select Inspect from the contextual menu
  2. In the HTML view which then appears, select the enclosing <a href="..."> or <button> etc element
  3. Ctrl-click again, this time choosing Copy > Copy XPath

The clipboard should now contain an Xpath string like

which you can paste into a Click Browser Link action (the old plugin is now superfluous and no longer maintained).

1 Like

You generally do not need a plugin to click a link via XPath now as XPath support is built in to current versions of Keyboard Maestro.

Thanks, both of you, for your response. Below are screenshots of the button and xPath from the code. I'm sorry, I cannot share the actual website without getting approval.

I've tried both the plugin and built-in action without success in this case. Maybe you can tell why by the images shared.

Not all HTML elements respond to clicks.

You would need to identify and target an element which does, for example:

  • any <a> element
  • a <button> element with a function defined for its onclick attribute
  • for style changes, possibly an element with a distinct style defined for :active or :focus

None of these are immediately visible in the element shown as selected in your screenshot, so you may just be clicking an unresponsive element.

Possibly some kind of interactivity is defined for the immediately enclosing div element, for example

I’m embarrassing. The reason the xPath action/plugin was not working is because the Macro “Group” I was working in was disabled. Enabling the group makes quite a difference. :flushed:

1 Like

No problem – happens to us all. Glad you found a solution.

Can I use wildcards?
The B000FCK9D6 bit changes, basically I want to go through the Amazon recommended items pagea and ensure they are all clicked so it doesn't use anything for my rcommendations. There are thousands of them over hundreds of pages and of course it's Amazon so no easy way to work on all of them.

Never mind, done it mainly in AppleScript with a KM wrapper.

1 Like