Micro Focus QTP (UFT) Forums
Verifying the sort function - 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: VB Scripting/Descriptive Programming (https://www.learnqtp.com/forums/Forum-VB-Scripting-Descriptive-Programming)
+--- Thread: Verifying the sort function (/Thread-Verifying-the-sort-function)



Verifying the sort function - mahadevan.swamy - 11-12-2008

Hi,

I have an application which contains a WebTable object and this application does a sort function. The only thing I want to do is that QTP has to verify if the sort is correct. For example, I want QTP to verify if the sort in the 5th column is correct or not. In this column I have about 20 entries. here is my code:

Code:
Browser("").Page("").Frame("").Image("Sort ascending").Click

a = Browser("").Page("_2").Frame("_sweview").WebTable("Select for MultiPay").GetCellData(2,5)
b = Browser("").Page("_2").Frame("_sweview").WebTable("Select for MultiPay").GetCellData(3,5)
c = Browser("").Page("_2").Frame("_sweview").WebTable("Select for MultiPay").GetCellData(4,5)
d = Browser("").Page("_2").Frame("_sweview").WebTable("Select for MultiPay").GetCellData(5,5)

If a<b and b<c and c<d Then
   Reporter.ReportEvent micPass, "Sort_Invoice", "Sort is correct"
Else
   Reporter.ReportEvent micFail, "Sort_Invoice", "Sort is wrong"
End If

Browser("").Page("").Frame("_sweview_8").Image("Sort descending").Click
a = Browser("").Page("_2").Frame("_sweview").WebTable("Select for MultiPay").GetCellData(2,5)
b = Browser("").Page("_2").Frame("_sweview").WebTable("Select for MultiPay").GetCellData(3,5)
c = Browser("").Page("_2").Frame("_sweview").WebTable("Select for MultiPay").GetCellData(4,5)
d = Browser("").Page("_2").Frame("_sweview").WebTable("Select for MultiPay").GetCellData(5,5)

If a>b and b>c and c>d Then
   Reporter.ReportEvent micPass, "Sort_Invoice", "Sort is correct"
Else
   Reporter.ReportEvent micFail, "Sort_Invoice", "Sort is wrong"
End If

Now I am told that I have to use arrays to verify the entire sort. Can anybody provide me a code or give me an example on how I can implement this array concept in this code. Thanks


RE: Verifying the sort function - hieutue - 11-14-2008

In my opinion, let try this way:
Scan all table
Get the value i and i+1, i is the row of table
compare two values and decide it true or false.
in crease i
Code:
for i=1 to (length_of_table-1)
   current=browser().page().webtable().getCellData(i,5)
   next=browser().page().webtable().getCellData(i+1,5)
   if current<=next then
       {.....}
   else
       {err msg}
   end if
next

Please correct me if I am wrong Smile