Select popup menu in Safari

I am now experimenting with Status Menu to automate a task frequently encountered. Here is the Safari window

It fills in the library card number fine; I am not sure how to get the drop-down menu selection (Select pickup Location) that comes next but would like to automate this to pull up the first choice in the menu, then have KBM fill in my email. (I do this a lot.) Is there a way to do that?

I tried just filling in the library number, then tabbing twice to get to the email slot; but for whatever reason it tabs down but doesn't fill in anything after the number. Maybe it was looking for something to do at the first tab down but got no instructions, then gave up?

Many thx

You can potentially use the Set Safari Field action to set the popup menu, if it is a well behaved form.

Thanks. Nearly there. I still can't figure out how to select a dropdown menu item.

This is the relevant section of the macro.

one thing I don't understand is the difference between Focus/Select/ and Set Field. Do you have to Focus then Select then Set field for each field?

There seems to be no variable for a dropdown selection when I place the cursor on the menu location in the web page and go back to KBM and click on the down arrow next to Safari". It simply shows something with "select one" appended.

So the question is how to trigger the selection action. tx

What is the extraneous text at the end of the Set field text?

If that field is correct, and the web page is the current front web page in Safari, then the current value should be shown before the arrow (bottom left).

select() only applies to text fields. focus() can apply to other fields. In practice they behave similarly. The DOM provides both, so I do as well, but I admit I'm not actually clear on the difference and searching didn't reveal a clear answer.

Use the menu to select the popup menu field you want. And then Keyboard Maestro will show you it's current value. Adjust the menu in Safari to the desired value manually, note the value down in Keyboard Maestro and use the value in the "to" field.

The "variables" shot is my error. The correct shot is the second one that shows

document.forms["patron_info_form"]["deliveryOptions"]

This is what the form produces when I am sitting in that field.

This is the value I want: (133 Doe Lib.)

Do I need to create a second macro command to add the desired value?

Or is the pattern supposed to be: Select field/ Set Field (x 3 in this case)?

(This doesn't work either)

Hey @jipnet,

Firstly:

When asking for help with Safari or Chrome actions that work with fields always provide the web address of the page you're working with – unless it is genuinely confidential. It is unlikely that you will get much useful help, unless people can run tests with the actual page.

It would appear that you're using the California Digital Library.

If you look at the values of the deliveryOptions field of the page in Safari's Web-Inspector you'll find the labels in the pop-up menu are NOT the values required by the page's code.

Field:

document.forms["patron_info_form"]["deliveryOptions"]

Values:

00 == Shields Library
01 == Health Science Library Circ Desk
02 == Medical Center, Blaisdell Medical Library
03 == Physical Sciences & Engineering Library
04 == Cadet-Hand Library, Bodega Marine Laboratory
05 == Law Library (Law School affiliates only)

The correct value is the number.

In sum:

This case perfectly demonstrates my first statement.

No one could give you the right answer for this problem without looking at the code of the web page in question.

The best they could do is guide you to do this yourself, and that is often very difficult to do.

See this vid for a brief demonstration of how to discover the needed information for yourself:

-Chris

4 Likes

Chris,

Thanks for taking the time to explain this and for the video. The video in particular made it clear what was wrong with the macros: yours shows a FOCUS/SET pattern (I had been trying SELECT/SET, which might also work, as Peter suggested), but each FOCUS macro in yours had a generic label: document.forms[0][0], whereas I was trying to fill in the specific fields in each of these cases (eg document.forms[“patron_info_form”][“barCode”] in the first field). The specific fields in your video show up only in the SET macro. So plainly the idea is first to focus generically and to set the specific fields (variables) next.

I didn’t realize that the information one manually enters (00 or email address etc) ARE the variables. I was confused by the option in KBM to select “variable” in the down arrow, the purpose of which is still unclear to me, but is not needed in this case.

I’ve now got it all working. Though I don’t fully grasp all the details, at least I got this far (works perfectly in fact), and never could have without your screenshots (and the tip about grabbing the code variable from the Safari Web Inspector).

So thanks again. A model of helpfulness.

Very nice video, Chris. I added it to:
Videos [Keyboard Maestro Wiki]

2 Likes

Great job, Chris!

1 Like

@ccstone Chris, Thanks for taking the time to make the video. Even though you explained this to me before with the Bank Statement Download macros, watching how you did it actually allowed me to pick up some extra awareness I didn’t have before.

1 Like

JM, Thanks for being proactive. Before long we should have an incredible video library resource!

1 Like

@ccstone’s video is excellent.

I will point out that Keyboard Maestro will tell you the value you need without having to use the inspector in Safari.

First, you select the desired form field in the Set Safari Field action:

Keyboard Maestro will show you what the current value of the field is at the bottom left. So in Safari, with the web page at the front, select the desired value (eg Law Library), and Keyboard Maestro will show you the required value is "05".

Chris’ method would be great to know if this does not work for any reason, but for most cases, if Keyboard Maestro can set the value, it can also read the value and so it will display the current value for you.

3 Likes

Hey Peter,

I didn't realize that.

Very spiffy!

-Chris