Hey guys,
I’m trying to identify the latest message received in a chat, the only unique this i got is the idx but i can’t seem to get the value. I tried the Get Attribute but it returns an empty string, or a different value if I try with the uipath_custom_id. Is there a way to get it? Or is there a better way to identify the latest message? I tried the anchor but I’m too newbie to get it to work
You could try using a loop to check all of the messages in the conversation thread. It is not the most efficient way, or elegant, but you could have a While Loop with a counter used in the idx section of a selector, that starts at whatever number you want, inside a Try Catch Then cycle through the messages until there is an error with finding an element. Then in the Catch part of your Try Catch you could add an assign to remove 1 from the counter, then use a Get Text to get the message.
I will attempt to make a rough example workflow so you can visualise it.
It is hard for us to tell how volatile the idx is as a selector. Sometimes you can utilize idx because the same value corresponds to the same location/item, but other times it will randomly change.
Similar to what @william.coulson mentioned, you could use a ‘find children’ activity on the parent element. Then use a ‘for each’ activity to loop through each element and pull out the text attribute. This may work all on it’s own, but sometimes there are hidden elements with blank text attributes, or other garbage data thrown in. If that’s the case, then you can add everything from the for each activity into a list, remove empty, blank, and null strings, remove duplicates, then take the last item in the list.
Let me know if you need help with any of the above and I can try and give concrete examples as I’ve done something similar a few times in the past