How to initialize UiPath.Core.UiElement


While using Get Attribute activity in a sequence getting Log Message: Object reference not set to an instance of an object. So tried putting child element default value as *New Enumerable.Empty(Of UiPath.Core.UiElement) but it’s throwing Type Enumerable.Empty is not defined message. Please let me know if I’m missing anything.


can we get screenshot

Uploaded. Please let me know if it’s fine or not.

Hi @rayabhijit2017,

I am not sure if you want to retrieve the UIelement attribute or are trying to get a standard html inner text. If you have already identified an UiPath Ui element in your workflow, then the retrieving the attributes within it will need a slightly different approach.

You can check the ongoing discussion in this link: Variable, Uielement

Hi @jeevith
Thanks for your response. I’m trying to retrieve a dropdown list in html innertext format which will be utilized in the succeeding loop for extracting more webportal details. Have used element exists activity prior to clicking dropdown and find children activity. PFA the screenshot.

While debugging it getting Object reference not set to an instance of an object msg. So tried putting child element default value as *Enumerable.Empty(Of UiElement)() As System.Collections.Generic.IEnumerable(Of UiElement) but it’s throwing End of Expression expected message.
Also checked the ongoing discussion in this link: Variable, Uielement but missed to find any resolution yet. Please let me know if you have any suggestions.

I tried to debug,

  • I have a question regarding the reason for using the get attribute here. Why is that needed?

I initialized the child1 variable to to New UiPath.Core.UiElement and the error disappears. I did this because your child1 variable type is a single UiElement.

1 Like

Thanks for your suggestions. I’ve earlier used Get Attribute activity for getting the Find Children “inner text” values from the dropdown. Thereafter removed the Get Attribute activity and used For each loop for extracting details for certain manufacturers which are captured in the selectedmanifacturerlist input argument string array. PFA debug screenshot getting at SendHotkey place. BOT is presently unable to enter into the happy path.

Please let me know if I’m missing anything.

Hi @rayabhijit2017,

I have not tested this on my machine, but the website you interface does run well on Chrome last time I checked. So have you tired a “Select Item” activity as an alternative instead of manually reading and sending hotkeys? May be that way you can avoid this error with the last part of that exception message.

Sorry for replying late. “Select Item” activity will select a particular item from the dropdown but I need to select all the dropdown items one after another and extract the necessary details. So, I’ve used send hotkeys and find children activity. It’s giving me the number of counts using modelseriesdropdown.Count.ToString expression but it’s giving result of one less than the actual dropdown number. Appreciate your suggestion.

May be the modelseriesdropdown selector outputs data in 0 index instead of 1 index?

Ok. Do you have any idea on how to choose (IEnumerable) default value in 0 index.

If I understand this correctly.

Your modelseriesdropdown is a zero index array while your IEnumerable by default is a 1 index array.
So what if you tried to add 1 to modelseriesdropdown? then you know that it will match the IEnumerable index.

for each item in modelseriesdropdown
yourIEnumerableUiElement.ElementAt(cInt(item)+1) will fetch the first value in the dropdown.

I have used such index tricks before when I used an image match (many similar images in the same application). All the image properties were imported in an IEnumerable variable with N length and with default 1 index. So what I did was to add 1 to my interested index so that I could get the 1st indexed value in the IEnumerable (which according to traditional programming is 0th index). This way you could also get the Nth index value

Thanks for your response. I’ve tried to assign a new IEnumerable value modelseriesdropdown.ElementAt(cInt(child)+1) for each item of for Each activity but it’s showing value of type UiPath.Core.UiElement cannot be converted to Integer.

Also tried with assigning a new argument modifiedmodelseriesdropdown with “IEnumerableUiElement.ElementAt(cInt(item)+1)” using Assign activity but it’s showing modifiedmodelseriesdropdown.count.ToString as 44 instead of 4. Please let me know if I’m missing anything

I have proposed a solution for this on your newer post: Issues with counting from a drop-down list

Hope it helps.