Highlighted
Absent Member.
Absent Member.
1291 views

[UFT] Compare value of List with DataTable

Hi,
in my application I have a ListBox, I get all items with:

allGroups = SwfWindow("myApp").SwfList("listBoxGroup").GetROProperty("all items")

that it returns me:
"item1
item2
item3
item4"

In my DataTable I insert in one cell this values
"item1
item2
item3
item4"

If I use an easy IF condition, it doesn't work:

If allGroups = DataTable.Value("groups_to_expected", "Step 1") Then
....my code
End If

The conditions is always FALSE.

Why?
Could be an error with new line char?

Thanks.

0 Likes
8 Replies
Highlighted
Absent Member.
Absent Member.

Could you explain how you Insert values into the Data Table. Do you do it manually or through scripts? I would want to take a look at the script where the data is inserted into the data table.

0 Likes
Highlighted
Absent Member.
Absent Member.

You could also save the items in an excel workbook (by entering all values in a single cell using line break) and then importing the workbook to UFT to check the condition.

0 Likes
Highlighted
Absent Member.
Absent Member.

I used an external excel sheet and I imported it into Datatable of UFT.

I copied multiline value in a single cell using ALT command.

0 Likes
Highlighted
Absent Member.
Absent Member.

Have you tried comparing the strings using strcomp()


Accept as solution/Give Kudos to the author if the piece of information answered/helped you to solve your problem.
All the thoughts here are mine not related to my employer nor anyone.
0 Likes
Highlighted
Absent Member.
Absent Member.

Of course, ma it doens't work!

0 Likes
Highlighted
Trusted Contributor.
Trusted Contributor.

Any luck? I'm struggling with a simpler version of your problem.
I have 2 variables. I capture one from a spreadsheet and the other from the subject line in outlook. . I want to compare the two and make sure they match . If they do, move on ( Next) If not, return a message saying they dont match. I have the Next loop working so I dont need help with that.
I'm certain my variables are captured. I have verified that with a msgbox.
*****
msgbox expSubject
msbox mailSubject.

Now.. I want to compare the two.

StrComp (expSubject, mailSubject, 1)

That line returns 1 but that means nothing to me. I need to do an If then Else for these two variables.

If expSubject is equal to mailsubject then loop to the next line , If not, give me a message saying the subject doesnt match.
0 Likes
Highlighted
Knowledge Partner
Knowledge Partner

Doesn't "all items" return a ; separated list?

Mark Smith,

0 Likes
Highlighted
Trusted Contributor.
Trusted Contributor.

I was able to get it to work by comparing the obj rather then the stings in the variable. 

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.