If you post a macro we can look at it.
Thanks for this custom action and the macro that proceeded it.
Can you confirm whether this action is all that is needed to “click” the item represented by the XPath (the macro needed an If/then statement to execute the XPath)? I have the following but can’t get it to click that item. The XPath comes from using Chrome’s Inspect; the same XPath works successfully in the macro.
applied to: document
Browser: Google Chrome
Also, Click Google Chrome item matching XPath doesn’t appear to accept a variable, so is it possible use a loop to click on multiple similar XPath items (download links to bank statements) such as:
I tried this macro and couldn’t get it to work. Here’s a short screencast showing what I did:
Can you tell me what I’m doing wrong? Thanks.
I think that plugin is currently broken.
Well, dang! LOL. Thanks for the reply.
I no longer have editing rights to the original post, alas, but I have now tracked down the problem (a shift in the optional status of the Results key), and this copy now works again on my system:
Had to watch my video to remember what I was trying to do!
Thanks for fixing it.
After a few hours of despair, I think I found the reasons, why so many people - me included - seem to struggle with this KM action. Most examples of XPath syntax use double quotes, e.g.:
However this does not work in the KM custom action. Because of the scripts it uses, it can only parse single quotes, so you need to write instead:
While searching for a solution, I found out that you can test and debug your XPath definition from the console within the Google Chrome developer tools. Just type:
But be aware that you need to use double quotes within your XPath there. So it becomes:
When your syntax is correct the console returns the full line of HTML you were searching for and when you hover the mouse pointer over the result, the actual element is also highlighted in the content area. From there you can just copy it into KM. But don’t forget to change the quote symbols back to single quotes
Hope this will save people some time. And by the way: A big thank you to @ComplexPoint for this great custom action. It is very helpful
Well done Julian!
any idea why it works in Chrome but not in Safari ?
Unfortunately I have no idea. I even gave it a try. My XPath syntax worked from the devel console from within Safari, but not when triggered from KM. So my guess is, that there is a problem with the custom action, that affects Safari only. Sorry. Maybe @ComplexPoint could have another look at it.
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?
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
<button> element in the HTML) :
- 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
- In the HTML view which then appears, select the enclosing
- 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).
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.