以后不在此处更新日志了,欢迎测友到新窝找我:http://www.wuchuanhu.cn/

QTP:搜索功能测试

上一篇 / 下一篇  2009-05-31 23:48:52 / 精华(2) / 个人分类:QTP&vbs研究

以下是一个用于测试某网站铃音搜索功能的脚本。

脚本首先使用childobjects对象把页面所有Link对象查找出来,其次使用正则表达式匹配每个子对象的运行时text属性(匹配模式为搜索框中输入的值),然后统计搜索到得结果,最后使用随即点击搜索到得下载链接。

缺点是:如果搜索的值为“更多”(页面上有同名且非铃音下载的链接),则可能打开的不是下载链接导致脚本执行失败。

脚本:

Browser("***").Page("****").WebButton("搜索").Click
Set  LinksDescription = Description.Create()
LinksDescription("html tag").value="A"
set  LinksChildObj=Browser("*****").Page("****").ChildObjects(LinksDescription)
 linkscount=LinksChildObj.count
Dim i,text,sertchResult
j=0
For i=0 to linkscount-1
text= LinksChildObj(i).GetRoproperty("text")
Set myReg= New RegExp
myReg.Pattern ="等一分钟" 
myReg.IgnoreCase = True
myReg.Global = True
If myReg.test(text) Then j=j+1
Next
'msgbox(j)
'msgbox(LinksChildObj(j-1).GetRoproperty("text"))
k=randomNumber(0,j-1)
msgbox(k)
LinksChildObj(k).Click


TAG: 搜索功能 QTP qtp

 

评分:0

我来说两句

Open Toolbar