Click item on Chrome or Safari page by XPath

xpath

#21

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:


#22

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.

-Chris


#23

I cannot get it to work!
version: keyboardmaestro 8.0.3

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


#24

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.


#25

thank you very much


#26

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”.


#27

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
//*[@id="post_26"]/div/div[2]/div[2]/section/nav/div/button[2]

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


#28

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.


#29

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.


#30

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


#31

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:


#32

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