QTP之无分页功能的查找脚本

TIB工作室成员 文青山 作品
 
 
无分页功能的查找脚本,其主体结构为“完全匹配查找”和“模糊查找”,按照Case的逻辑需要进行修改,缺点是当表列的数据很多时,检查的速度太慢了,
有没有更高的效率去查找,目前还不得而知。


Dim compterName          '本机名
Dim fucationPath              '函数地址
fucationPath="F:\qtptest\fucation\fucations.vbs"  '函数组件
ExecuteFile fucationPath
CloseIE()     '调用组件中的CloseIE(),结束IE进程
CloseExcel()   '调用组件中的CloseExcel(),结束Excel进程
Url "XXXXXXXXXXXXXXX" '导航
login(username,password) '登录
Dim  checkTest1
Dim  checkTest2
Dim check
Dim totalRowNumber
Dim totalColumNumbe
'下拉框的值
checkTest1="技术预研"
'输入框的值从global表中获得
checkTest2=DataTable.RawValue("test2","Global")
Browser(" ").Page(" ").Frame(" ").WebList("Value0").Select checkTest1 '查找字段
Browser(" ").Page(" ").Frame(" ").WebEdit("Value1").Set checkTest2    '查找字段
Browser(" ").Page(" ").Frame(" ").WebButton(" ").Click
totalRowNumber=Browser(" ").Page(" ").Frame("name:=RightBottomFrame").WebTable("class:=CommonTable CommonSubTable BugMode").RowCount
'完全匹配查找,即所查找的列必须与关键字的字段一致,如果某一行不一致,则退出fail
For i=2 to totalRowNumber
 '获取某列的值
 text1=Browser(" ").Page(" ").Frame("name:=RightBottomFrame").WebTable("class:=CommonTable CommonSubTable BugMode").GetCellData(i,2)
 
 '如果没有trim()方法,老是报错,不晓得为啥子,仔细看text1里面也没有空格
 
 If  trim(text1)=trim(checkTest1) Then
  check=true
 else
  check=false
  i=totalRowNumber
 End If
Next
'模糊查找,使用qtp自带函数RegExpTest(),经试验这里的检查作用相当于模糊查询了,不需要自己再构造正则表达式,只要存在checkTest2则返回,否则为空
For j=2 to totalRowNumber
 '获取某列的值
 text2=Browser(" ").Page(" ").Frame("name:=RightBottomFrame").WebTable("class:=CommonTable CommonSubTable BugMode").GetCellData(j,3)
 If  RegExpTest(checkTest2,text2)<>""  Then
  check=true
 else
  check=false
  i=totalRowNumber
 end if
Next
If check=true Then
 CloseMsgByTime "pass"
else
 CloseMsgByTime "fail"
End If

Browser(" ").Page(" ").Sync
Browser(" ").CloseAllTabs


 

posted on 2011-04-06 13:14  TIB  阅读(415)  评论(0编辑  收藏  举报

导航