Validating Sorted WebList. The below code excludes default selected value (i.e. –Choose One–) from validation.
Code
Dim oPage:Set oPage=Browser("name:=QTP").Page("title:=QTP")
arrCtry=Split(oPage.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=oPage.WebList("name:=select1").GetROProperty("all items")+";" Then
Msgbox "The Weblist's values are sorted in alphabetical order"
Else
Msgbox "The Weblist values are not sorted in alphabetical order"
End If
Comments(0)