Browser Form Filling

This is a set of three macros I made today.

The three macros together let you save the data you have entered into a form, and then fill it in on command. So if you have a form you need to fill in multiple times with variations, you can save most of the data, and just make the changes for each one. My common usage for this is entering multiple children into a camp form.

The three macros are run in sequence:

  • Load up the form in Safari or Chrome, and leave it blank.
  • Run the Snapshot Start Form. The macro saves the state of the empty form.
  • Fill in the form.
  • Run the Snapshot Read Form. This saves the difference, ie all the data you have entered, into a variable * Captured Web Field Data*. It displays the fields in a text window, but you can turn that off if you want.
  • Submit the form, and then reload the page.
  • Run the * Snapshot Set Form*. This fills the form with the saved data.
  • Make any changes, submit the form and repeat.

It needs work to extend it to be really useful, but it's a solid start.

Primary deficiencies:

  • it only saves a single form. Ideally the forms would be saved for each web page, or each domain or something.
  • it doesn't currently handle popup menus.

So if anyone wants to take this and run with it, I'd be very happy to see a @DanThomas job done to it :slight_smile:

BTW, for anyone who wanted to know about uses of dictionaries, this macro makes use of them to speed up the processing significantly.

Browser Forms Macros.kmmacros (21 KB)

4 Likes

At some of my former places of employment, doing a “Dan Thomas job” wasn’t necessarily a positive thing. :stuck_out_tongue:

Glad to know that’s not the case here. Thanks for that, it made my day. :blush:

6 Likes

Thanks for the macros, Peter. Looks very interesting.
I was reading your macros, trying to understand them, and ran across this at the bottom of 03)Snapshot Set Form macro:

No, I just was originally going to do the field setting in JavaScript, and then I came to my senses and let Keyboard Maestro do the work instead :slight_smile:

That action does nothing, just delete it.

Wow, you've all really given me some ideas here! :smiley:

I run a PC repair shop and fill out forms for new tickets multiple times a day. I'm tinkering with this and read about how to get the form ID's to do this manually. I am lost with a few things though, maybe one of you could help?

Several parts of my forms have dropdown/list menus. I can't figure out how to pick from my lists. I also can't find the ID for one button to click to send the filled out form. There are two buttons on the form to submit and no matter which ID I've selected, it uses the first option. If anyone has the time and expertise to make any suggestions, I would really appreciate it!

New Ticket - New Customer 2.kmmacros (18.0 KB)
New Ticket - New Customer.kmmacros (8.7 KB)
HTML.zip (1.6 MB)

 <div class="btn-toolbar right">
      <input type="submit" name="commit" value="Create Customer" class="btn btn-sm btn-success">
      <input type="submit" name="commit" value="Create Customer And Ticket" class="btn btn-sm btn-success">
  </div>

In Safari (you might need to turn on the Show Develop menu in menu bar in the Advanced preferences), you can control click on an element on a web page and select Inspect Element.

Control click on the "<input" text, and select Copy XPath.

That will give you something like this:

//*[@id="new_customer"]/div[2]/div/input[1]

Then create a Click Front Browser Link action and paste that in:

That will click the Create customer button.

Repeat for the second button.

//*[@id="new_customer"]/div[2]/div/input[2]
4 Likes

I have been able to get the XPaths from Safari to work, except for when a website uses frames. Is there a way to work with those? The XPath that I copy and use just gives the error that it couldn't find it.

Hey Michael,

Welcome to the forum!   :smile:

Don't forget to search.

Selecting XPath in iFrame - #2 by peternlewis

-Chris

Thank you. I did see that post but I didn't see any replies from anyone that would indicate whether it solved their problem or not. I can get what's shown to work, but to what end? I end up with a variable called HTML with source of the frame inside of it. I have no more information on where to go next.

Thank you for your reply!

Neither do we...  :sunglasses:

  • Post your website if you can.
  • Post your XPath.

-Chris

The website it intranet only, so I can't share it.

The XPath leading up to the iframe is as follows:
/html/body/krn-app/krn-navigator-container/ui-view/krn-workspace-manager-container/krn-workspace/div/krn-layout-manager/div/div[4]/krn-widget/krn-widget-content/div

If I get the XPath on the iframe, I only get:
//*[@id="widgetFrame1642"]

The source for the button I want clicked is:
Screen Shot 2021-11-04 at 8.11.28 AM

The XPath for the <cc-button...> line is:
//*[@id="mainWidgetContent"]/ui-view/krn-timestamp/div[3]/cc-button

Or do I need to click the which has the XPath:
//*[@id="jqxWidgetd006f30125da"]

Does that help?