Saturday, March 27, 2010

How To Check Elements In A Weblist Are In Alphabetical Order


arrCtry=Split(Browser("name:=QTP").Page("title:=QTP").WebList("name:=select1").GetROProperty("all items"),";")

Set objArray=DotNetFactory.CreateInstance("System.Collections.ArrayList","")

For i=0 to Ubound(arrCtry)
If arrCtry(i)<>"--Choose One--" Then
objArray.Add(arrCtry(i))
End If
Next

objArray.Sort()
objArray.Insert 0,"--Choose One--"

For j=0 to Ubound(arrCtry)
strOuput=strOuput+objArray(j)
strOuput=strOuput+";"
Next

If strOuput=Browser("name:=QTP").Page("title:=QTP").WebList("name:=select1").GetROProperty("all items")+";" Then
Msgbox "The Weblist's values are sorted in alphabetical order"
Else
Msgbox "The Weblist's values are not sorted in alphabetical order"
End If
I hope the above snippet is useful.

1 comment: