Serialize and Deserialize dictionary (string, uielement)t

How to serialize and deserialize a dictionary containing string (as key) and uielement (as value)?

Use case:
Using “indicate on screen” activity when robot runs. The output is a uielement. Alternative method when click fails, send hotkey fails. So user needs to make robot “learns” once only.

Thank you.

Hi @GreenTea

Use add to dictionary and create dictionary variable as do config (Dictionary of string,uielement and check the condition as doconfig(“columnname”). ToString and do the manipulations

Thanks
Ashwin.S

Hi Ashwin,

I have create the config variable which is dictionary(of String, UiElement) already. But I need to write to file (serialize) and read (deserialize) from file. It is to keep persistent data.

Hi @GreenTea

As far as I know, UIElement is a class which consists of a group of data related to the ui element you denoted. if you try to write it, it will return the object as uielement., instead of that, you can assign the value of dictionary as the selector , I mean, uielement.selector which will store the selector of that particular object so you can pass it to the selector property

Hi Hareesh,

The selector works if I am did not checked selectregionscreen for “indicate on screen” activity. However, I need to draw a rectangle around the selected value from a drop down list. So I still need to write value as UiElement.

Thank you.

There is clipping region to store in that @GreenTea. But not sure that will solve the issue you have

Hi Hareesh,

Thanks for pointing me in the right direction and help me get going. Once I have the complete solution will share with community forum.

Thank you Hareesh.

Hi @HareeshMR,

I found the UiElement.ImageBase64 as best suited for my use case as the screen resolution and size may varies. Using a few assign activities to converts ImageBase64 to UiPath.Core.Image and pass the image variable as Input to Click Image activity.

The reference for converting base64 to image can be found here

Since ImageBase64 is a string, I can write/read to dictionary(of String, String).:smile:

1 Like

Thanks for sharing the info and helping the mates @GreenTea

You are a LIFE SAVER!!! Thank you for sharing your solution!