Difference Between Working with JavaScript in a Web Browser Console and in Keyboard Maestro

Last week (31) I heard about Keyboard Maestro. So I jumped in this week with a first exercise and got stuck shortly after. The goal is to use shortcuts to fill out an HTML form. Before creating a form from scratch, I visited w3cschools and their form sample Tryit Editor v3.6 via Safari and opened the 'console' via Developer Tools. My simple javascript 'document.getElementById('email').value="joo"' works fine. When I do the same with KM, I get the error 'TypeError: null is not an object (evaluating 'document.getElementById('email').value="joo"')'. Working with 'document.forms[0][0]' with the text 'xyz' fill I did not get to work. Maybe I don't understand the KM approach to filling Safari web forms yet. Maybe someone has a screenshot and/or a working macro to fill 'joo' in the form field with the id 'email' aka first form field [0]. Thank you in advance

IS the web page publicly available? If so, what is the link.

If not, what is the HTML of the web page?

For example, this works:


or this:


But it depends on your web page.

Especially if the web page uses frames or JavaScript that change the page as it loads, it can be quite challenging.

1 Like

Thanks @peternlewis for your quick and concise reply.

In the meantime I created a page with the w3c school HTML code.... e voila KM works and so does a JavaScript in Apple's Script Editor.app.

Now I understand your approach with the 'set field' and using parts of the HTML structure.

1 Like