Refining data from GetVisibleText activity

I need to grab data from a multiline web-component. On the paper it contains 2 or 3 head items and can expand into a tree. I select the data and for long it seemed to work. Suddenly it doesn’t. I iterate each item to determine the node to expand. Suddenly it consistently selects the wrong node. It may be because of an update but I don’t think so.

Data I get is in this form: “\n\n\nItem1 Item2 \nItem3 \nItem4 Item5 Item6 Item7 \n”

I expected to see Item1 to Item3. The rest has snug in from somewhere. Furthermore, the first two items aren’t separated by an “\n”, so I do this in a for-each activity:

text.Replace("\n", null).Trim().Split(" "))

… and get the error “Cannot convert from string to char”. Can’t see where the “char” thing turned up. It’s all strings to me. Can anyone please help me?

I also saw that the data returned from GetVisibleText was a GenericValue. Changed that to a string to be able to use the string manipulation functions.

Studio Pro 2020.10.4-beta.1 - 1/26/2021
Community License

Microsoft Windows 10 Enterprise 64-bit
.NET Framework Version 4.8 or later

Hello @HenrikCarlsen
solution for your issue is :
text.Replace("\n", null).Trim().Split(" “c)) or
text.Replace(”\n", null).Trim().Split(" ".ToCharArray))

my suggestion is to use regex with pattern “Item[0-9]{1,3}”
more help on using regex is below

That little ‘c’? Will it do the trick. Well, it didn’t, but it led me onto a solution: text.Replace("\n", null).Trim().Split(’ ') - simply changing the split parameter to a char.

I haven’t considered to use regex on the items (which I renamed to item<n> here). They are always the same four items and their names don’t interlock, but <space> is a perfectly fine separator and I just skip the garbage.

Thank you for your help.

1 Like