Dealing with dynamic drop-down list

text
activities
studio

#1

Hello.

I have an empty field where I can type some short text, let’s say it’s a company name. When I type this name a drop-down list appears. Depending on the typed text there may be three cases:

  1. The drop-down list consists of one record which is the company name.
  2. The drop-down list consists of more than two identical records (literally you get several options which have absolutely the same name).
  3. The drop-down list is empty (let’s treat it as if the company is not in the database).

I need to learn to distinguish all these three cases and make further actions depending on which case it is.

Any ideas on how to do it? I thought of playing with the Type Into activity and keys like “down” or “up” to get the number of records in the drop-down list. But I genuinely think it’s a bad idea because the list is always dynamic, it’s also unclear how to let the robot understand when to stop pressing those buttons and so on and so forth.

I would be grateful to read your ideas if any exist.


#2

Did you try with ‘Find Children’ activity? Filter with the appropriate selector that has those dynamic values.

You can have the list of all the elements matched as filtered by this activity and then you can check whether it has 0 or more elements.

Let me know if it works.

Thanks,
Rammohan B.


#3

Hi @MGMKLML

Maybe you could type in the company name and then see if you can use Element Exist with dynamic selectors in a loop to determine the amount of options in the list. Keen if it works!

Bas


#4

I think your solution is the more robust solution!


#5

@basvanderpol, @Rammohan91 Thank you for your replies. I’m going to be checking it the next week, but I wanted to collect ideas because this is what I don’t understand initially.


#6

Here is an example of what I have done in the past to select items in a dropdown when the words are dynamic.
image

So, assuming the dropdown has a selector and that you can access its “items” attribute, you can get all the items found, then select the item you want by filtering it (In my case, I used .Where and .Contains() as my condition.

To be honest, it’s similar to using Find Children but simpler. So I guess it’s preference.

So that is one way if it helps.

Regards.


#7

@Rammohan91 But how can I create those values in the selector if I never know whether there will be options or not. I haven’t dealt with the ‘Find Children’ activity yet but I’ll take it into consideration.


#8

When you get all the items in the dropdown stored in a list or array, you can use list.Count to see if there were items found.


#9

@ClaytonM Thank you for your reply. In my case it will work similar to what we have in Google. When we start typing a request we get ‘hints’. In my case I may have similar ‘hints’, one ‘hint’ and no ‘hints’ at all. All these cases are to be distinguished.


#10

However, if the items contain empty strings then you might need to join the list together, like

If String.Join("",list).Trim = ""

#11

@ClaytonM That being said, I’m afraid that the likes of ‘Find Children’ will have no effect as it’s not ‘constructed’ like a list with items. You type ‘a’ and then you get all the hints starting with ‘a’. You add ‘b’, that is ‘ab’, you get all the hints with ‘ab’ at the beginning. Just like you search something in Google, with the only difference being that you can’t exactly know how many ‘hints’ you’ll get.

How the ‘Find Children’ activity will behave in this case?


#12

What text will you be inputting in that textbox? Suppose you type a company name as ‘abc’ and then the popup appears with around 10 matched values. ‘Find Children’ activity will capture all the 10 elements if your selector is dynamic enough.

Again if you run the same workflow but this time having the input as ‘xyz’ which may have only 2 matched values, output of the ‘Find Children’ activity will have only those 2 elements.

Is that not what you are looking for?

Thanks,
Rammohan B.


#13

@Rammohan91 Thank you. At least it sounds close to what I want. I will play around with this activity during the next week and if something goes right or wrong I’ll let you know. It’s just the case when I started thinking before doing :smiley: