UI automation = Drop down Automation select value contained

Hi,

The model var = “YARIS T3 SPIRIT”

I want it to select the value from the dropdown.

how can I get the text from dropdown which includes (Intro.03/06)

My automation must check model var is contained in the drop down value how can I do this?

image

Hi @Aki1111

Check below if I understand correctly,

  1. Use Find Children activity on the dropdown element.

    • Set Filter to "<tagname='option' />" (for <select> dropdowns)
  2. Use a For Each loop to get the inner text of each option:

    For Each item In dropdownOptions
        Log Message: item.Get("innerText").ToString
    Next
    
  3. Store the values in a list if needed:

    dropdownValues = dropdownOptions.Select(Function(item) item.Get("innerText").ToString).ToList()
    

Hi @Aki1111,

Try exploring the drop down selector, usually this would come under attribute “aaname” or innertext.
So, you can modify your selector of select item accordingly to fill in the required value by setting dynamic value(variable) for aaname or inner text property.

Alternatively, if you won’t know in advance what value can come after “YARIS T3 SPIRIT (Intro”, you can refer below method of typing it in and using a hotkey combination.

Hope this helps.

Regards
Sonali

I need to make the inner text a wildcard

like I have the innertext which contains the item to be selected which is a variable but how do I make it a wildcard.

Hi,

So the issue is I need to make the innertext a wild card.

like I have the innertext which contains the item to be selected which is a variable but how do I make it a wildcard.

Hi @Aki1111

If you want to match any text that includes your variable value dynamically, use:

selectedItem = dropdownOptions.FirstOrDefault(Function(item) item.Get("innerText").ToString.ToLower().Contains(variableValue.ToLower()))

If you need more complex wildcard matching (like * for any characters), use Regex:

import System.Text.RegularExpressions

selectedItem = dropdownOptions.FirstOrDefault(Function(item) Regex.IsMatch(item.Get("innerText").ToString, ".*" & Regex.Escape(variableValue) & ".*", RegexOptions.IgnoreCase))

I hope you will found helpful, tick as a solution or let me know.
Thanks

@Aki1111

Try to achieve using 2 clicks instead of going with Select option

Step 1: Assign the value you are expecting to select into a variable. As mentioned - only the static value in the drop down
Step 2 : Click on the drop down arrow
Step 3 : For development - select any drop down value and keep the option as strict selector. Make sure the drop down value like inner text or AA name is included in the property
Step 4: Modify the selector to make it dynamic

Refer attached workflow created for public academy site and modify the selector accordingly

ForumProject.zip (800.3 KB)

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