I am using KM to fill a form field in Safari. Each time the page is reloaded the ID of the form field ID changes the string of numbers inside the ID. Is there a way to use a wildcard selector with the Select Safari Field action?
example of ID change
#owner_address_attributes_usr112132300__province
turns into
#owner_address_attributes_usr282132304__province
Is there a way to parse this natively in KM? Something like…
I think that can very likely be done with XPath, but I don’t offhand know how.
I think you can discover the tag by using something like:
var docTags = document.getElementsByTagName('*')
And iterating through them with a regular expression to find the right one – but someone more conversant with JavaScript will have to help you with that.
What I personally would do in the absence of these other techniques is to grab the source of the page and parse it with the AppleScript and the Satimage.osax.
If I found the relevant field-name then I’d proceed accordingly.
You can do something similar with pure JavaScript though:
var docSrc = document.body.parentNode.outerHTML;
var regEx = /(owner_address_attributes_usr\d+__province)/igm;
var matches = docSrc.match(regEx);
matches.join('\n');
For now try that on for size, and perhaps in time one of our better JavaScripters will chime in with something better.