DropDownList对象是WebElement时的取值方法

由于在QTP中,对于下拉列表的对象默认是WebList,但是研发人员自己开发下拉列表后,对象发生变化,对象变成WebElement,以下就是针对开发自定义下拉列表取值方式:


1.     开发自定义下拉列表取值方法一个页面中有多个下拉列表,且对象属性值一样,如何参数化且遍历取值?)

Set objPage =  Browser("name:=XXX").Page("title:=XXX")

'检查回放模式   1、表示事件跟踪模式  2、表示鼠标跟踪模式
Setting.WebPackage("ReplayType") = 2


>>‘在没有参数化时,只针对页面中一个下拉列表取值

SelectDropDownBox objPage,"DropDownListName","DropDownListValue"


>>‘参数化多个下拉列表,针对当前页面中所有下拉列表取值

Fori = 1 to 2

SelectDropDownBox

objPage,DataTable("TitleName",dtGlobalSheet),DataTable("DropDownValue", dtGlobalSheet)

DataTable.GetSheet("Global").SetNextRow

Next


'主体代码-------------------------------------------------------------------------------

If  ListNum.count =1 Then

         ListNum(0).Click

End If

Public FunctiongetItemList(PageObject,PropertyName,PropertyValue)

        Dim oDesc

        Dim n

         Set oDesc = Description.Create

        If isarray(PropertyName) andisarray(PropertyValue) Then

                  DimiCountPropertyName,iCountPropertyValue

                  iCountPropertyName =ubound(PropertyName)

                  iCountPropertyValue =ubound(PropertyValue)

                  If iCountPropertyName <=iCountPropertyValue  Then

                            For n = 0 Toubound(PropertyName)

                                     oDesc(PropertyName(n)).value=PropertyValue(n)

                            Next

                  Else

                           Exit Function

                  End If

        ElseIf (not isarray(PropertyName)) and(not isarray(PropertyValue)) Then

                   oDesc(PropertyName).value=PropertyValue

        Else

                   Exit Function

         End If

         set getItemList =PageObject.childobjects(oDesc)

End Function


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值