Validating Sorted WebList Values - Codoid
Select Page
Codoid Blog

Validating Sorted WebList Values

Irrespective of the business that your client is in, marketing is an integral part of their operations. In fact, in this day and age of social.

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
  

Written By

Submit a Comment

Your email address will not be published. Required fields are marked *


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