How can I record actions in Safari with KM so they work regardless of window size or position?

I'd like to record my inputs into an online database form (in Safari) using KM, so I can automate the process later. The problem is that when I record, KM always uses "Move and Click" to select a field. This saves the exact screen coordinates of the click.

This makes it very difficult to replay the action reliably, because it depends heavily on the size and positioning of the Safari window. If I move the window or resize it, the click no longer hits the right spot.

Is there a way to record my actions so that KM captures the field name, HTML ID, accessibility tag, or some other more stable identifier instead of the screen position? Or is there an alternative method to automate form entries in a browser-independent and reliable way?

This might be useful.

1 Like

So the easiest solution is to start your macro with an Action that sets the position and size of the Safari window to what's required!

A better solution would be to use other methods to activate and input into each field in turn -- you'll probably find you can Tab through the form's input fields, so can alternate "Insert by typing" with "Keystroke: Tab" Actions.

The best method is to set field values using JavaScript -- if the form uses static identifiers KM can glom onto. Take a look at the Wiki's "Browser Form Actions" for how to discover and set field values/checkboxes/radio buttons, and try the "Press a Button" Action to submit the form.

And you can roll your own JavaScript field-setting using @noisneil's most excellent macro, above.

If this is a publicly-available resource then post the URL and someone may be able to give more detailed help.

1 Like

Great, thanks!

Clever!

I will try this!

I’m a bit afraid to work with javascript, but will have a look at the wiki.

If this is a publicly-available resource then post the URL and someone may be able to give more detailed help.

Unfortunately, its an internal database.