Unlike @carycrusiau, I wasn’t able to get this to work at all. As a test I used the example in the previous macro to see if I could even get it to click the search box on the page & no luck. Nothing happens in either Chrome or Safari.
What else can I provide to get help in getting this to work?
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.
XPath: //*[@id=“downloadDocumentLink0”]
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:
/[@id=“downloadDocumentLink0”]
/[@id=“downloadDocumentLink1”]
/*[@id=“downloadDocumentLink2”]
etc.
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:
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.:
//*[@id="search-button"]
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:
//*[@id='search-button']
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:
$x('<your_xpath_definition>')
But be aware that you need to use double quotes within your XPath there. So it becomes:
$x('//*[@id="search-button"]')
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
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.