How to get count of drop-down values

Hi Team,

Please let me know which expression or activity should i use to know how many values present inside the drop down and also there total count.

Hi @Smitesh_Aher2

You can use Get Attiribute activity to do this.

Make sure the variable type (items) is an array. Then you can find the number of values by items.Count

Regards.

@Smitesh_Aher2,

Refer this.

Hey @tolga.kamci Thanks for your response.

Actually the attribute as ‘items’ is not showing in the activity.

After using find children activity it’s showing only 2 count only.

@Smitesh_Aher2,

This could be due to the dropdown items are getting loaded dynamically while we one and scroll. Check if that’s the case.

@Smitesh_Aher2

In find children did you select descendants in scope?

Also can you show the selector of it

Cheers

The attribute with the name “items” is not offered in the Attribute dropdown (get Attribute Activity) but still is usable. Just enter it manually (respect letter cases)

Hey @Smitesh_Aher2,

To get the count of values in a drop-down (i.e., a Select element on a webpage) in UiPath, you can use the “Find Children” activity along with some expressions. Here’s how you can achieve this:

Solution using Find Children:

  1. Use the “Find Children” Activity:

    • Drag and drop the “Find Children” activity.
    • Indicate the drop-down element on the screen.
    • Set the Scope property to FindDescendants.
  2. Filter to Get Only Options:

    • In the Filter property, set it to:
      "<webctrl tag='option' />"
      
  3. Count the Drop-down Options:

    • Use an Assign activity to get the count:
      dropDownCount = childrenList.Count
      
    • Where childrenList is the output variable of type IEnumerable<UiElement> from the “Find Children” activity.
  4. Example Workflow:

    • Find Children → Output: childrenList
    • AssigndropDownCount = childrenList.Count
    • Now, dropDownCount will hold the total number of items in the drop-down.

Alternative Approach using Get Attribute (for drop-downs with a known structure):

If the drop-down has a Select tag with a defined list of options:

  • Use the “Get Attribute” activity.
  • Set the Attribute property to “innerhtml”.
  • Split the resulting string by "<option" and get the count of items:
    dropDownCount = dropDownHtml.Split(New String() {"<option"}, StringSplitOptions.None).Length - 1
    

Notes:

  • Make sure to set the proper selectors for the drop-down.
  • The Find Children approach works well for dynamically generated lists.

Hope this helps! Let me know if you need any more assistance.

Cheers! :blush: