Micro Focus QTP (UFT) Forums
Comparing webtable data with weblist and webelements in other webpage - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: UFT / QTP Beginners (https://www.learnqtp.com/forums/Forum-UFT-QTP-Beginners)
+--- Thread: Comparing webtable data with weblist and webelements in other webpage (/Thread-Comparing-webtable-data-with-weblist-and-webelements-in-other-webpage)



Comparing webtable data with weblist and webelements in other webpage - arnav - 04-07-2014

Hi Guys,

I need script for the following scenarios.

1. Comapring names in a webtable in a webpage with the names in the weblist in another page.

2. Comparing dates in a webtable in a webpage with the dates the dates in other webpage displaying as a webelement

Please help me on this. I need that urgently.


RE: Comparing webtable data with weblist and webelements in other webpage - Parke - 04-18-2014

Arnav:

The following code has not been tested. I would use an arrayList as elements can be added or removed without having to reDim a normal vbscript array.
Code:
Set arrL_1 = dotnetfactory.CreateInstance("System.Collections.ArrayList")
Set arrL_2 = dotnetfactory.CreateInstance("System.Collections.ArrayList")

numRows = browser(b).Page(p).WebTable(nme).RowCount
print "num rows = " & numRows
''assume your column names/header is row one
'' add the names to the first arraylist
for i = 2 to numRows
    arrl_1.add browser(b).page(p).webTable(nme).getCellDate(i,columnNames)
next


'' for a list
'' do not remember if a list count starts with zero or one
list_count = Browser(b).page(p).WebList(listName).getROProperty("items count")
for j = 0 to list_count - 1
    browser(b).page(p).webTable(nme).getCellDate(i,columnNames)
Next

'' you can sort the arrayLists
arrL_1.sort
arrL_2.sort
[\code]


Another method would be to create a strtable and a strList.

[code]
strTable = ""
for i = 2 to numRows
    strTable = strTable & browser(b).page(p).webTable(nme).getCellDate(i,columnNames)
next

strList = ""
for j = 0 to list_count - 1
    strList = strList & "::" & browser(b).page(p).webTable(nme).getCellDate(i,columnNames)
next

'' do a split on the two strings, strList_arr = split(strList,"::") and compare these arrays.

There are lots of examples of how to compare two arrays.
hth,

Parke