Trouble with Select from drop-down list

I’m unable to select a certain text from a drop down list.
The data that will be selected from the drop down list is dynamic and will change depending on what type of item it’s working with. So for example… If these are my items…

  • Apple

  • Strawberry

  • Mango

If I choose apple, my selections are going to be:

  • Bitter Granny

  • Red Delicious

But If I choose Strawberry I might get:

  • Frozen

  • Fresh

This is just an example. In reality, My sublist has 20 items or so.
I’ve created a variable called selectText that will hold the text that I would like to select from the dropdown list.

Here is the tricky part…
It’s not a Select Web attribute, it’s a div. So I can’t use the Select Activity because it’s not supported by the current node…Or whatever…

This is the selector for the div, where I believe each text field is a SPAN

"<webctrl id='rc' parentid='"+parentidRow+"' tag='DIV'/>"

I’ve tried a type into activity, but that only works if I only type in one letter, it will select whatever the first thing is that starts with that letter. That’s not going to work because I have multiple items in my list starting with the same letter. It won’t always select the correct item.

I also tried clicking on the dropdown, and then using a click text activity right afterwards. Any other ideas would be greatly appreciated.

Hi Heather,

You can try with a normal Click activity and use UiExplorer to get a selector for the element that you want based on the text it contains. For that, you can use the aaname property, which means the actual text of the control. Exactly what you want, to click on the control with that particular text. Of course, you’ll set the value from a variable, as in the example with the parentid.

Usually, if you check the Simulate Click property of the Click activity, you don’t need the first click on the dropdown. Try it and see if it works.

Regards
Silviu

1 Like

So the problem is that the field that I’ll be selecting is dynamic. I have a String variable with the aaname that I want it to click on, I’ve tried putting my variable in the selector. It’s just not having it. The element that I want it to select is a SPAN. The attributes that contain the text I want to click on are innertext, innerhtml, and aaname. Is there a way I can set the inner text of the SPAN to my variable?

So the only thing I’ve been able to get working so far, is using the find children activity. The only thing I would want to change, is instead of returning all of the children I only want to return the children with the aaname that I’m wanting to click on. When I try to do that I get an error:

Unable to cast object of type ‘Newtonsoft.Json.Linq.JValue’ to type ‘System.String’

I’m getting that error only when I try to use
“” as the filter, on my find children activity.

Can you attach a screenshot / details about the selector and what other properties are available for that element in UiExplorer? It would help to understand the issue.

How did you put your variable in the selector? Is should work that way.

Find Children activity is another good approach for this, but you need to put something in the filter field. At lease leave the default value there or even better would be to have a filter that will give you exactly the element that you want. But again, more details (screenshot) with the application structure and the activity configuration that you are using will be helpful.

I was in the process of doing that, but I did end up solving my problem. I used a find children activity to find the items in the drop downlist, then I had to filter them, but it worked.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.