Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Verifying the sort function
#1
Solved: 11 Years, 3 Months, 4 Weeks ago
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
Reply
#2
Solved: 11 Years, 3 Months, 4 Weeks ago
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
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Calling a Function in Function Library when function is defined in an Action jitenderkkr 0 2,973 11-27-2014, 12:53 PM
Last Post: jitenderkkr
  Custom sort -Excel Sheet kiran 1 3,868 01-28-2014, 09:23 AM
Last Post: supputuri
  How to sort different dates in and get the Max date from those nilanjans 2 5,715 09-07-2012, 07:35 AM
Last Post: vIns
  How can I fetch server time using function Now or any other function? blanchedsouza 2 5,115 11-07-2009, 08:34 PM
Last Post: Ankur
  Verifying value in calculated field janriis 1 2,115 04-21-2009, 06:10 PM
Last Post: dvkbabu

Forum Jump:


Users browsing this thread: 1 Guest(s)