Variable, Uielement

How can we see the value of variable of type
Uielement?
Is it like the selector Inthe form of tags ?

1 Like

@Kiran_Kumar
uielementvar.attributes will return a string array with all attribute keys

using this in a for each activity allows us to retrieve all available info on this element by:
uilelementvar.Get(“attributekeyname”)

Also have a look here on a prepared inspection approach:

1 Like

Hey @Kiran_Kumar,

The UiElement variable is basically an object holding element related properties & metadata.

Try using below code for getting the selector of that element.

UiElem.Selector.ToString

Assuming, UiElem is the variable name (you can change to yours)

Thanks :slight_smile:

2 Likes

Hi @Kiran_Kumar,

Both approaches from @ppr and @Nithinkrishna will work. I am here adding to their answers.

UiElement is an interesting argument type in windows UiPath, but beware they are not so easy to debug, especially if you have many matches of similar elements. So parsing and making the workflows using UiElements robust will usually be a demanding excercise. It also depends on the way the interfaced application is designed.

For argument type UiElement
Then you can use the following to get the corresponding keys and values.

yourUiElement.GetNodeAttributes.Keys(Index)
yourUiElement.GetNodeAttributes.Keys(Index)

Maximum Index here will be number of Key value pairs in your UiElement and this can be dynamic. For example, an image identified in an application can have a (x,y) position, which will be captured in a UiElement key value pairs for each x and y.

For argument type IEnumerable(UiElement)
If you have many UiElements which are matched using for example, FindImageMatches activity. Then you will first get all the matches in form of an IEnumerable argument type.

To get the key and values from such a variable you can use the following

yourIEnumerableUiElement.ElementAt(IEnumerableIndex).GetNodeAttributes.Keys(Index)
yourIEnumerableUiElement.ElementAt(IEnumerableIndex).GetNodeAttributes.Keys(Index)

IEnumerableIndex here can start from 0 to a maximum of yourIEnumerableVarible.Count.

Finally, in both of the above, you can use For Each activity to loop through the values you are interested in.

UiPath.Core.UiElement != System.Windows.UiElement
Here is the link to the official Documentation of UiElements: UIElement Class (System.Windows) | Microsoft Docs

we should not do a missmatch
the uielement from e.g. a find element etc. is from namespace UiPath.Core

Agreed.
I realize they are two different namespaces. Sadly, UiElement description in UiPath is quite frail. I will edit the link in my previous post.