|
Someone solved this issue in sqaforums
Function IsRegEqual(s_Text, s_Pattern)
Dim regEx, retVal ' Create variable.
Set regEx = New RegExp ' Create regular expression.
regEx.Pattern = s_Pattern ' Set 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
' for example
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 |
|