How to detect a select menu is blank

I’m automating filling out a web form that has dynamic Select menus. One of these only populates when valid data is found. If no item is found the form doesn’t give a validation error, it just shows a blank selector.

I thought I could ignore that and just catch the validation error that shows up when the submit button is clicked. However, Studio never gets that far. Instead, it times out on not being able to select an item and throws “Cannot select item. It was not found among existing items.”

Ideally, I’d like the bot to realize there are zero items in the selector, log the error, and continue onto the next item in the workflow. I guess I’m looking for something like an “if selector is blank then…” construct, but I’m unclear on how to do that.

Any suggestions?

Seeing the full error makes me wonder if there is some “list length” kind of equivalent I could use? Hopefully someone out here in the community can give me a nudge in the right direction. :slight_smile:

Select Item ‘SELECT list1’: Cannot select item. It was not found among existing items.
TIP: Some combo-boxes delay load items until its dropdown is expanded. Try to simulate a click on control prior to selecting an item.

Hi,

The following post might help you.

Regards,

1 Like

Your knowledge is superb.

This didn’t get me the answer, but led me to the right path. By getting the full text of the select list I found that the select never populated when no asset was found. It appeared to be blank, but was actually still populated with the invisible string value of “Loading…”.

An invisible list with a length of 1 is indistinguishable from a proper list length of 1 - so I had to throw out my math idea. However, because the string value is “Loading…” rather than an asset number, I was able to use a string match to set up an IF block to catch the empty select list and move on to the next item.

I thank you sincerely for this vital clue. :bowing_man:

1 Like

You could also use a try catch on your select activity. That Will catch your error ss intended :slight_smile:

I would love to make Try/Catch work - but was unclear how to detect this error. I don’t see any validation error on the page, just in UiPath’s logs where it says:
“Select Item ‘SELECT list1’: Cannot select item. It was not found among existing items.
TIP: Some combo-boxes delay load items until its dropdown is expanded. Try to simulate a click on control prior to selecting an item.”

At that point the bot has already failed so it doesn’t help me skip the error and move on.

Any suggestions towards properly using Try/Catch here would be much appreciated.

Full Solution I ended up using for this was:

[Sequence]
[GetFullText] (of the Selector), output to strListOfSelections Note: Change the “WaitForReady” property to Complete
[Assign] intListLength = strListOfSelections.Split(vbCrLf.ToCharArray,System.StringSplitOptions.RemoveEmptyEntries).Count
[IF] intAssetListLength = 0 then throw mark this row as a problem and CONTINUE

I’ve tested it now several times and it’s working great.