Selecting an option from a drop down list

If an app has a drop down selection on one of its fields

e.g. Field is Quality

Drop down is Low or Med or High

What is the best way to select , say Med from down list?

PS Do not ask me for app etc as this is a general question.

Unfortunately it's very much about the app -- or even the particular list in an app, as not all dropdowns are the same. The "best" way is the one that's most reliable for a particular situation.

For web apps there's JavaScript, of course.

For "normal" apps (or web apps where JS won't work) I'd try keystrokes -- can you type to select a list item? Keystroke: M would be enough in this case, or you could Insert text by typing: med. In either case you may need a short Pause before the Keystroke: Return, particularly in slow-to-respond cases like Electron apps.

If you can't letter keystroke, try and keystrokes instead. They work best when the list is fixed and it always starts with the same (or no) item selected. You can still use arrow keys with lists that default to the last-selected item if you can't arrow past the top (or bottom) item -- lists where the default item changes and arrowing up from the top takes you to the bottom (and vice versa) or a non-starter.

Then I'd try AppleScript and System Events -- it's more work (and less likely to be supported) than the following methods but, IMO, is more robust.

Image detection would be next. You can usually get a good enough search image to pick from a list, especially if you narrow down the search area as much as you can and don't restrict the capture to just the list item you want -- capturing a bit of the items above and below can often help.

And there's clicking at coordinates. Popups are often in a fixed position relative to one of the window's corners or another part of the UI you can "Find Image" on, and a list that doesn't default to the last-chosen item will usually have its elements at consistent coordinates too.

There's probably other ways of doing this, too! But I hope this gives you some ideas to try the next time you want to select from a dropdown.

2 Likes

Thanks for comprehensive reply.
Any one else want to pitch-in?

What could we possibly add to @Nige_S' comprehensive answer? :slight_smile:

He laid out pretty much all the options, and in exactly the same order in which I'd try them.

-rob.

1 Like

Not sure what is meant by this. Am I scanning the underlying JS code for something? If so, how do I do it?

Again -- "it depends". It might be as easy as using KM's "Set Front Browser Field" Action or it might involve some heavy spelunking in the page's code and you then writing your own JS with involved selectors to target the right field.

So try the KM Action first :wink: Here's a little demo of that. First, a simple web form -- save this code out in a file with an .html ending then open that with your browser:

<html><head><title>Test Form</title></head>
<body>
	<form id="form1">
		<label for="field1">Field 1</label>
		<select id="field1">
			<option value="low">Set It Low</option>
			<option value="med">Med</option>
			<option value="high">High de High!</option>
		</select>
		<label for="field2">Field 2</label>
		<select id="field2">
			<option value="1">1</option>
			<option value="2">2</option>
			<option value="3">3</option>
		</select>
	</form>
</body>
</html>

And all you need to set "Field 1" to "Medium" is:

If you play around you'll pick up on two important points:

  1. The field values aren't necessarily the same as the drop down's items -- you set to the value
  2. Value is case-sensitive -- while setting "Field 1" to "Med" will work in that you've set a value, you'll see that the drop down is blank because there's no corresponding option. Med ≠ med.
1 Like

Thanks for all your work in this. Will try it out.