I am trying to use the Execute JavaScript in Safari-action to get some information from a webpage.
This is the code document.getElementsByClassName("ui-dialog-content");
It works if I execute it in the console in Safari.
But when running it in KM it does not return anything.
I can not give access to the page, but I have used this JavaScript (which works in KM) document.body.innerHTML
to get a sample HTML.
Sample-html: http://d.pr/f/1jJ57
There is not anything in the logs which shows an error.
Hope somebody can point me in the right direction to get this to work.
Yes. JavaScript access for AppleEvents is enabled.
I have also tried the same JavaScripts in Chrome and it is the same.
Nothing returns for document.getElementsByClassName("ui-dialog-content");
Unfortunately this did not work.
At my company we have some web-developers and they have also tried to help me to find the best JavaScript to extract the data.
My own test now has in the JavaScript Console in Safari lead me to this code, which has a narrowed my data down. document.getElementsByClassName("ui-jqgrid-bdiv").item(1);
But it does still not return anything from Keyboard Maestro.
As I said, getElementsByClassName returns an array of node elements. This is something Safari’s console can display in some form, but not something that makes any sense in a Keyboard Maestro variable.
So you need to convert it from that array of nodes in to whatever format you actually want. For example, something like this:
This works in a Keyboard Maestro Execute JavaScript in Safari action, and returns something, but whether it is what you want for an array of nodes, I have no idea.