Just beginning to learn QTP, learn the example of database connection
The script is as follows:
Browser ("Test Login"). Page ("Test Login"). Webedit ("uname"). Click
Browser ("Test Login"). Window (People Selection-web dialog box). Page ("People selection"). Frame ("Contentleft"). Link ("Personnel department"). Click
Browser ("Test Login"). Window (People Selection-web dialog box). Page ("People selection"). Frame ("Basefrm"). Link ("Hoeven"). Click
Browser ("Test Login"). Window (People Selection-web dialog box). Page ("People selection"). Frame ("Botfrm"). Image ("btn_gb_on"). FireEvent "onmouseover"
Browser ("Test Login"). Window (People Selection-web dialog box). Page ("People selection"). Frame ("Botfrm"). Image ("btn_gb_on"). Click
Browser ("Test Login"). Page ("Test Login"). Webbutton ("Login"). Click
Browser ("Test Login"). Page ("Office automation System"). Frame ("Leftframe"). Link ("Official document Management"). Click
Browser ("Test Login"). Page ("Office automation System"). Frame ("leftframe_2"). Link ("In-Receipt management"). Click
Browser ("Test Login"). Page ("Office automation System"). Frame ("leftframe_2"). Link ("in-query"). Click
Browser ("Test Login"). Page ("Office automation System"). Frame ("MainFrame"). Webedit ("Oareceivebumf.bumfname"). Set "in-Test"
Browser ("Test Login"). Page ("Office automation System"). Frame ("MainFrame"). Image ("btn_cx_on"). FireEvent "onmouseover"
Browser ("Test Login"). Page ("Office automation System"). Frame ("MainFrame"). Image ("btn_cx_on"). Click
' DBTable ("Dbtable_4"). Output CheckPoint ("Dbtable_4")
Dim nn
Nn=datatable.globalsheet.getparameter ("P_text"). Value
Browser ("Test Login"). Page ("Office automation System"). Frame ("MainFrame"). Output CheckPoint ("78")
Dim mm
Mm=datatable.globalsheet.getparameter ("Mainframeoutput_text_out"). Value
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; "
Connecting Oracle Databases
Cmd.commandtype = 1
Sql= "SELECT COUNT (*) from OA_RECEIVEBUMF where bumfname as like '% in ' in test% '"//Fuzzy query, query name contains total number of "in-Test" records
Sql= "SELECT COUNT (*) from OA_RECEIVEBUMF where Bumfname= '" &nn& ""
Cmd.commandtext = sql
Set res = Cmd.execute ()
MsgBox Res (0)
If CStr (res (0)) = CStr (mm) Then//cstr converted to strings
Reporter.reportevent micpass, "test", "Query Success"//judgment is equal, equality output "query success"
Else
Reporter.reportevent micfail, "test", "Query failed"
End If
Set res = Nothing
Set cmd. ActiveConnection = Nothing
Set cmd= Nothing
Browser ("Test Login"). Page ("Office automation System"). Frame ("leftframe_2"). Link ("Logoff"). Click
Browser ("Test Login"). Page ("Test login _2"). Sync