TA的每日心情 | 开心 2015-1-10 09:52 |
---|
签到天数: 1 天 连续签到: 1 天 [LV.1]测试小兵
|
本帖最后由 da乐 于 2012-3-20 11:26 编辑
百度了下
Function IsRegEqual(s_Text, s_Pattern)
Dim regEx, retVal ' 变量
Set regEx = New RegExp ' 创建正则表达式 .
regEx.Pattern = s_Pattern ' 模式
regEx.IgnoreCase = True
IsRegEqual = regEx.Test(s_Text)
End Function
Function SelectByText(objWebList,s_Text,b_RegExpression)
Set obj_Options=objWebList.object.options
i_Count =obj_Options.length - 1
For i=0 to i_Count
If b_RegExpression And IsRegEqual(obj_Options(i).text,"^"+ s_Text) Then
obj_Options(i).selected=True
Exit for
Elseif Lcase(s_text)=Lcase(obj_Options(i).text) then
obj_Options(i).selected=True
Exit for
End If
Next
End Function
Function SelectByValue(objWebList,s_Value,b_RegExpression)
Set obj_Options=objWebList.object.options
i_Count =obj_Options.length - 1
For i=0 to i_Count
If b_RegExpression And IsRegEqual(obj_Options(i).value,"^" & s_Value) Then
obj_Options(i).selected=True
Exit for
Elseif Lcase(s_text)=Lcase(obj_Options(i).value) then
obj_Options(i).selected=True
Exit for
End If
Next
End Function
Function SelectByIndex(objWebList,i_Index)
objWebList.object.options(i_Index).selected=True
End Function
下面是例子:
SelectByText Browser("Find a Flight: Mercury").Page("Find a Flight: Mercury").WebList("fromPort"),".*ond.*",TRUE
SelectByValue Browser("Find a Flight: Mercury").Page("Find a Flight: Mercury").WebList("fromPort"),"san.*francisco",TRUE
SelectByIndex Browser("Find a Flight: Mercury").Page("Find a Flight: Mercury").WebList("fromPort"),3 |
|