Micro Focus QTP (UFT) Forums
Sort Order Check - 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: Sort Order Check (/Thread-Sort-Order-Check)



Sort Order Check - automation2012 - 03-06-2013

Code:
Set oDesc=Description.Create()
oDesc("micclass").value = "WebElement"
oDesc("class").Value = "order_details_main_boxes"
Set sLinks = Browser("ABC").Page("XYZ").ChildObjects(oDesc)
sLinkCount = sLinks.Count
For i = 0 to sLinkCount - 1
iName= sLinks(i).GetROProperty("innertext")
iOrderNumber =Left(iName, 7)
aSort(i) = iOrderNumber
PRINT aSort(i)
Next

Assume i have 3 orders for my user in the application.

so order numbers are stored in an array aSort(i) using the above code. (Note: webtable is not availble and so caputured orders by taking class value of webelement)

aSort(0) = 1
aSort(1) = 2
aSort(2) = 3

Now in the order page orders are displayed in the following order:

Order Column -- Link
2
3
1

Now if i use click method and click on Order Column link then orders will be displayed in descending order

Order Column
3
2
1

Need code to check whether they are displaying properly in descending order or not.

Again if i click on Order Column link it is displayed in ascending order. Need code to check whether it is displaying in ascending order or not.

Please help me in this regard.

Thanks.


RE: Sort Order Check - automation2012 - 03-07-2013

SOme1 please reply if you know the answer..


RE: Sort Order Check - automation2012 - 03-26-2013

Code:
Set oDesc=Description.Create()
oDesc("micclass").value = "WebElement"
oDesc("class").Value = "order_details_main_boxes"
Set sLinks = Browser("Browser").Page("Page").ChildObjects(oDesc)
sLinkCount = sLinks.Count
PRINT "sLinkCount " &sLinkCount
For i = 0 to sLinkCount - 1
iName= sLinks(i).GetROProperty("innertext")
iOrderNumber =Left(iName, 7)
iDate = Right(Left(iName, 20), 10)
aSort(i) = iOrderNumber
PRINT "AppSort "&aSort(i)
Next

Public Function fnSort()
   For j = 0 To sLinkCount - 1
    For k = j + 1 To sLinkCount - 1
        If aSort(j) > aSort(k) Then
            sTemp = aSort(j)
            aSort(j) = aSort(k)
            aSort(k) = sTemp
        End If
    Next
Next
End Function

fnSort()
For j=sLinkCount - 1 to 0 Step - 1
    sDescArr(j) = aSort(j)
    PRINT "sDesc " &sDescArr(j)
Next

fnSort()
For j=0 to sLinkCount - 1
    sAscArr(j) = aSort(j)
PRINT "sAsc " &sAscArr(j)
Next


I have got the code to check the sort logic but failed to check the validation....

need some help in this regard....i need to compare application order sort and the sort which i got from the logic i used above....