非常实用的QTP学****笔记
转贴一个高人的QTP笔记供大家学****br/> 文章比较长,一共三部分:
1、连接数据库查询例子,无参数化
//查询收文操作,通过数据库查询记录数是否正确
//1、输出记录数值,例如78条 2、获取输出的记录数值 3、连接数据库,查询记录数
4、输出记录数值和从数据库中查询记录数值,相比较,相等则成功,不等则失败
Browser("湛江信息化测试登录").Page("湛江东兴石油企业有限公司办公自动化系统").Frame("mainFrame").Output CheckPoint("78")
Dim mm
'mm=("mainFrameOutput_Text_out").Value
//注释,获取datatable值与DataTable("mainFrameOutput_Text_out", dtGlobalSheet)一致
mm=DataTable("mainFrameOutput_Text_out", dtGlobalSheet)
MsgBox mm
Dim res,cmd,sql
Set res=createobject("")
Set cmd=createobject("")
= 1
sql="select count(*) from oa_receivebumf where BUMFNAME like '%收文测试%'"
'sql="select count(*) from oa_receivebumf where BUMFNAME='"&nn&"'"
//注释,sql语句,等于时sql语句
// sql="select count(*) from oa_receivebumf where BUMFNAME like '%nn%'" //like时sql语句
= sql
Set res = ()
//msgbox res("name")
MsgBox res(0)
If Cstr(res(0)) = Cstr(mm)Then
micPass, "test", "查询成功"
else
micfail, "test", "查询失败"
End If
Set res = nothing
Set = nothing
Set Cmd= nothing
2、登记用户,查看是否登记成功
//登记用户,查询用户是否存在在数据库中
1、 参数化 2、取参数化值 3、查询语句中,赋值给查询条件
4、从数据库中查询出用户名,与参数化中值做比较
脚本如下:
Browser("测试登录").Page("办公自动化系统").Frame("mainFrame_2").WebEdit("").Set DataTable("p_Text", dtGlobalSheet)
Dim xname
xname=DataTable("p_Text", dtGlobalSheet)
MsgBox xname
Dim res,cmd,sql
Set res=createobject("")
Set cmd=createobject("")
= 1
sql="select name from address_list t where name ='"&xname&"'"
= sql
Set res = ()
'msgbox res("name")
MsgBox res(0)
Set res = nothing
Set = nothing
Set Cmd= nothing
第二部分
1、Datatable方法GetRowCount
("Action1").GetRowCount //获取总行数
使用如:
CountNum=DataT
非常实用的qtp学习笔记 来自淘豆网www.taodocs.com转载请标明出处.