51Testing软件测试论坛

 找回密码
 (注-册)加入51Testing

QQ登录

只需一步,快速开始

微信登录,快人一步

手机号码,快捷登录

查看: 1828|回复: 2
打印 上一主题 下一主题

[原创] 正则表达式能不能用在下拉框的值选择?

[复制链接]

该用户从未签到

跳转到指定楼层
1#
发表于 2008-5-29 16:08:39 | 只看该作者 回帖奖励 |正序浏览 |阅读模式
我有一个下拉框,
Browser("").Page("").Frame("").WebList("").Select "1000 Items"
我想让它表示成 1000*,怎么写?
能想到的我都试过了,都报错,对象不存在...
我使用对象库的。
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏
回复

使用道具 举报

该用户从未签到

3#
发表于 2008-5-30 10:28:10 | 只看该作者
Browser("").Page("").Frame("").WebList("").Select " text:=1000"&".*"
回复 支持 反对

使用道具 举报

该用户从未签到

2#
发表于 2008-5-30 10:11:19 | 只看该作者
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
回复 支持 反对

使用道具 举报

本版积分规则

关闭

站长推荐上一条 /1 下一条

小黑屋|手机版|Archiver|51Testing软件测试网 ( 沪ICP备05003035号 关于我们

GMT+8, 2024-9-21 21:48 , Processed in 0.087306 second(s), 29 queries .

Powered by Discuz! X3.2

© 2001-2024 Comsenz Inc.

快速回复 返回顶部 返回列表