IEnumerable < TextInfo > variable type


#1

I’ve got a string of text on a form and I’m trying to use Get visible text to get the WordsInfo so I can search the results, find a text match that I need, get the screen position/coordinates of the match and then click on it. The screen position is what I need.
The WordsInfo is returning a OutArgument of IEnumerable but I’m not sure how to access the data that is held in it? I’ve tried For each and the item.ToString just returns “UiPath.Core.TextInfo” rather than the data inside it.

Any ideas would be gratefully received.

Dave


#2

Hi,
In For each loop you have to change the argument type.


Get text color
#3

Thanks for that - I’m now getting the error message:

Risk Selector Form Test has thrown an exception

Source: For each

Message: Unable to cast object of type ‘UiPath.Core.TextInfo’ to type ‘System.Collections.Generic.IEnumerable`1[UiPath.Core.TextInfo]’.

Exception Type: InvalidCastException

System.InvalidCastException: Unable to cast object of type ‘UiPath.Core.TextInfo’ to type 'System.Collections.Generic.IEnumerable1[UiPath.Core.TextInfo]'. at UiPath.Core.Activities.ForEach1.InternalExecute(NativeActivityContext context, IEnumerator valueEnumerator)
at UiPath.Core.Activities.ForEach`1.Execute(NativeActivityContext context)
at System.Activities.NativeActivity.InternalExecute(ActivityInstance instance, ActivityExecutor executor, BookmarkManager bookmarkManager)
at System.Activities.ActivityInstance.Execute(ActivityExecutor executor, BookmarkManager bookmarkManager)
at System.Activities.Runtime.ActivityExecutor.ExecuteActivityWorkItem.ExecuteBody(ActivityExecutor executor, BookmarkManager bookmarkManager, Location resultLocation)

And I’ve tried changing the argument type in the For each to use both System.Collections.Generic.IEnumerable<UiPath.Core.TextInfo> and UiPath.Core.TextInfo but nothing happens. I’m trying to display the output as a string (each item in the IEnumerable) so I can see it’s format and work out the parts I need to extract.


#4

Hi,
It’s just a matter of mismatch of data conversion type.(looks like source itself is of form textinfo)
Do you mind attaching workflow.


#5

Risk Selector Form Test.xaml (13.2 KB)
Hi - attached is the test flow.
Ignore the top part - that worksd fine. The issue I have is after the Log message that discplays "Driver: " & DriverText,ToString.


#6

Hi,
Use UiPath.Core.TextInfo Its working.
In message box you can’t use just item.tostring instead use methods available
methods
ex: item.Color.ToString


#7

Wow,
Thanks ddpadil - that worked. I appreciate your help.