Show Value of all available Attributes for a given UI element

For a given UI element, I would like to see the value of every available Attribute that can be shown via GetAttributes activity. Note: I’m not try to get the list of Attributes, I’m trying to get the actual value of each attribute for a specific UI element. Ideally I’d like to be able to view this while debugging, but other than create 30+ GetAttribute activities, is there any way to see all of an element’s attribute values? Thanks.

1 Like

Hello @mdagosta

You’ll get element’s attribute names with element.Atrributes. You can then get attribute values by name with element.Get(name).

ForEach attr in element.Attributes (attr is a String)

  • Assign (Object)
    value = element.Get(attr)

  • LogMessage
    String.Format("{0} ({1}): {2}", attr, value.GetType.ToString, value.ToString)

If you want the attribute of your browser element, look for browser.Element.Attributes.

7 Likes

Thanks msan. This mostly works, but it’s throwing errors “Attribute not supported by the current UiNode”. Curious, doesn’t the UIElement know that it doesn’t support that Attribute? Why would it try to enumerate an Attribute that it doesn’t support?

Hi @mdagosta

Could you please give more context about what is failing (debug, flow, …)

msan, Yes, thanks for your kind help. (FYI: I am very new to UIPath) The real objective is to loop through all of the items in a Dynamics SL2018 grid. While researching that, I discovered that you can use the “Find Children” activity to cycle through all the UIElements in the selected object.

So:

  • Find Children returns “elements” (type = IEnumerable) in the “Children” output property.

  • For Each element in elements (outer loop)

  •    For Each attr in element.Attributes  (inner loop)
    

Within each of the loops I do “Write Line” activity to track what’s being viewed, summarized below. The Attributes are assigned to an Object variable using the element.Get(attr) method and that “Assign” is what is failing.

Element #1 = “ScrollBar”
Attribute #1 = App.Path: C:\Program Files (x86)\Microsoft Dynamics\SL\Applications\CA
Attribute #2 = PID: 8572
Attribute #3 = TID: 2060
Attribute #4 = aaname:
Attribute #5 = aastate: focusable
Attribute #6 = app: 2021000.exe
Attribute #7 = cls: ScrollBar
Attribute #8 = foreground: False
Attribute #9 = hasFocus: False
Attribute #10 = hwnd: 591456
Attribute #11 = isMDIChild: False
Attribute #12 = position: UiPath.Core.Region
Attribute #13 = relativeVisibility: True
Attribute #14 = role: scroll bar
Attribute #15 = (ERROR: Attribute not supported by the current UiNode)

It appears to be the “sapClient” attribute of the scroll bar that causes the problem, during the Assign activity.

Thanks,
Mark

1 Like

Hi Mark,

Thank you for this overview. I would like to understand this situation too. I’m noob in VB but it migh be interesting to see if the result is the same by replacing element.Attributes by System.Attribute.GetCustomAttributes(element).

Could you please use UiExplorer on this scrollbar and look in Property Explorer pane if you see this attribute?

Well, you can’t use “element” as the argument for GetCustomAttributes because the data type is wrong. I did check UIExplorer for the scroll bar attributes and “sapClient” is not one of them. I’m not sure how UIPath implements its For… Each loops but in other languages (like VB), “For each x in y” would only enumerate x’s that were in y ! And every x should be convertible into data type “Object”. Mysterious :slight_smile:

well, for your case you might be good with a Try/Catch at each iteration but the underlying mecanism is still bugging me. I don’t thank you :wink:

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