学习qtp笔记1

    技术2022-05-11  45

    1、连接数据库查询例子,无参数化//查询收文操作,通过数据库查询记录数是否正确//1、输出记录数值,例如78条 2、获取输出的记录数值  3、连接数据库,查询记录数4、输出记录数值和从数据库中查询记录数值,相比较,相等则成功,不等则失败Browser("湛江信息化测试登录").Page("湛江东兴石油企业有限公司办公自动化系统").Frame("mainFrame").Output CheckPoint("78")

    Dim mm'mm=DataTable.GlobalSheet.GetParameter("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("adodb.recordset")Set cmd=createobject("adodb.command")Cmd.activeconnection="DRIVER={Oracle in OraHome92};SERVER=HKORACLE;UID=USER;PWD=ZJLH;DBQ=HKORACLE;DBA=W;APA=T;EXC=F;XSM=Default;FEN=T;QTO=T;FRC=10;FDL=10;LOB=T;RST=T;BTD=F;BAM=IfAllSuccessful;NUM=NLS;DPM=F;MTS=T;MDI=Me;CSR=F;FWC=F;FBS=60000;TLO=O;"Cmd.CommandType = 1sql="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语句Cmd.CommandText = sqlSet res = Cmd.Execute()//msgbox res("name")

    MsgBox res(0)If   Cstr(res(0)) = Cstr(mm)Then

          Reporter.ReportEvent micPass, "test",   "查询成功"       else  Reporter.ReportEvent micfail, "test",   "查询失败"End If

    Set res = nothingSet cmd.ActiveConnection = nothingSet Cmd= nothing

    2、登记用户,查看是否登记成功   //登记用户,查询用户是否存在在数据库中     1、 参数化 2、取参数化值  3、查询语句中,赋值给查询条件     4、从数据库中查询出用户名,与参数化中值做比较   脚本如下:Browser("测试登录").Page("办公自动化系统").Frame("mainFrame_2").WebEdit("addressVO.name").Set DataTable("p_Text", dtGlobalSheet)

    Dim xname xname=DataTable("p_Text", dtGlobalSheet)MsgBox  xname

    Dim res,cmd,sql

    Set res=createobject("adodb.recordset")Set cmd=createobject("adodb.command")Cmd.activeconnection="DRIVER={Oracle in OraHome92};SERVER=HKORACLE;UID=USER;PWD=ZJLH;DBQ=HKORACLE;DBA=W;APA=T;EXC=F;XSM=Default;FEN=T;QTO=T;FRC=10;FDL=10;LOB=T;RST=T;BTD=F;BAM=IfAllSuccessful;NUM=NLS;DPM=F;MTS=T;MDI=Me;CSR=F;FWC=F;FBS=60000;TLO=O;"Cmd.CommandType = 1sql="select  name from address_list t where name ='"&xname&"'"Cmd.CommandText = sqlSet res = Cmd.Execute()'msgbox res("name")

    MsgBox res(0)

    Set res = nothingSet cmd.ActiveConnection = nothingSet Cmd= nothing


    最新回复(0)