English 中文(简体)
Some validations to be done for a weblist or drop down list in VB Script
原标题:
  • 时间:2010-01-25 05:41:10
  •  标签:
  • vbscript
  • qtp

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 




相关问题
QTP - testing while browser/page title changes

I am trying to make simple testing but failed because I have no clue how to handle with browser title that changes during the testing. Simple example: Google>Find "blabol" Once its done, the browser ...

QTP - 取得要素价值

我从QTP开始,仅仅找不到如何获得要素的价值。 例如,当我只想比较一下从山洞中发现的成果数量时。 我试图用物体选择这个要素......

Record enter button in qtp

How to record ENTER button that we use through the keyboard in QTP for applications

How do you write your QTP Tests?

I am experimenting with using QTP for some webapp ui automation testing and I was wondering how people usually write their QTP tests. Do you use the object map, descriptive programming, a combination ...

Dynamically building a URL in QTP

I ve been taking a quick look at QTP with one of our test team. We ve figured out some basics like recording a test, capturing text using output values, putting in check points, etc. However, I can ...

热门标签