tags:

views:

232

answers:

1

I have a weblist or drop down list in my application which consist of many items.

I don't know the count but I need to validate the following -

  1. Validate that none of the items are duplicated
  2. Verify none of the items are numeric
  3. Verify all items are in sorted state.

Please suggest your respective solutions in VB Script

I want to execute this script in QTP tool (automation testing tool)

+1  A: 

The WebList all items property supplies all the properties in a semicolon delimited list.

In order for a list to be sorted it's enough that each item will be strictly greater than the one before it.

all = Browser("B").Page("P").WebList("L").GetROProperty("all items")
arr = split(all, ";")
a = arr(0)
For i = 1 to UBound(arr) -1
    b = arr(i)
    cmp = StrComp(a, b)
    If cmp = 0 Then
        MsgBox "Duplicate"
    ElseIf  cmp > 0 Then
        MsgBox "Unordered"
    End If

    If isNumeric(b) Then 
        MsgBox "Numeric"
    End If

    a = b
Next
Motti
One more verification rule to add: (2) - "Verify none of the items are numeric".If isNumeric(b) Then MsgBox("Numeric")End If
Albert Gareev
Thanks @Albert, I missed that bullet...
Motti