开发者

Some validations to be done for a weblist or drop down list in VB Script

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)


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


aTest = Array("adf","bfdsdf","xdfds", "efgdfg" ,"fdfsdf","gdfsfs","idfgdfg")

bResult = True

for i=0 to uBound(aTest) -1

    if asc(aTest(i)) < asc(aTest(i+1)) OR asc(aTest(i)) = asc(aTest(i+1)) Then
        bResult = bResult AND True
    Else
        bResult = bResult AND False 
    End If
Next

msgbox "Main result:"&bResult


'if bResult return true then array is sorted else it is not sorted 
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜