As I wrote: ElementsTable.Rows(0).Item(1) returns Object instead UiElement.
âdisallows implicit conversion from âObjectâ to âUiPath.Core.UiElementââ
Did you ever find a solution to this? Iâm running into the same problem trying to store a UiElement in a Dictionary(of string, object) and getting it back out as a UiElement to use in a Click activity.
I found that using DirectCast(MyDict(âSome Keyâ), UiPath.Core.UiElement) worked, although for my purposes it was a less than desirable solution so I just stored the UiElement in a variable separate from the dictionary.
Ugh, this was difficult to find info on. However, I did find a working solution.
Side note: using the Build Datatable activity wouldnât work to store a UiPath.Core.UiElement datatype; I had to use the activity Add Data Column â just FYI.
Retrieving the UiElement from the datatable is done by assigning it to a variable in a For Each Row in Data Table activity before using it â if you create the variable using the Ctrl+K shortcut, be sure to open the Variables panel and change the type to UiPath.Core.UiElement:
Note that in the Assign activity I had to wrap the saved UiElement data from the datatable with CType, which casts it back to the UiElement datatype from how itâs stored in the datatable.
I save the UiElement into the datatable the same way youâd save anything in a datatable:
Buuuuuut my above solution comes up against many problems.
TL;DR: Solution = Save the UiElementâs Selector instead of the entire UiElement; then use that as the Strict Selector when you need that UiElement.
I can always extract the first UiElement from the datatable, but Iâm lucky if the 2nd doesnât come out without a â!â for its Attributes or Selector properties, or ânullâ for its ImageBase64 or _cachedSelector/_cachedAttributes properties.
Seems the reason is due to a large amount of data stored in the Attributes and Selector properties. I tried a number of things, but the best turned out to be saving the Selector to the datatable (since my use-case is to use the elements in the next step of my automation, almost immediately, and hence not much chance for change, and knowing my scraped elements wonât change until a page refresh). I use that saved Selector String in my Click activityâs Strict Selector property, and it picks it right up.
FYI, my research indicates saving UiElements is at the limit of retrieval on Windows machines, in large part because UiPath needs to maintain compatibility with many 32-bit programs. As such, the message pipes a 32-bit program is limited to means we can use the absurdly large amount of data it takes to pass just one UiElement as part of a datatableâs row â itâs just too much.