Dim qtp_test,url,function_lib,object_repository
qtp_test= "C:\Program Files\Mercury Interactive\QuickTest Professional\Tests\google -description programming"
url="www.google.com"
function_lib="C:\Testing\vbs\REGEX.vbs"
object_repository="C:\Program Files\Mercury Interactive\QuickTest Professional\CodeSamplesPlus\Flight_Samples\SOR.tsr"
'-------------------------------------------------------------
Set qtp=createobject("quicktest.application")
Call addins()
Call global_settings()
set ie=aut()
Set xl=createobject("excel.application")
xl.visible=true
Set wb=xl.workbooks.add
Set ws=wb.worksheets("Sheet1")
For i=1 to 3 step 1
with ws.cells(i,1)
.value=i
.font.colorindex=(i*10)
.font.size=i+5
.font.bold=true
.font.name="Arial"
.interior.colorindex=(i+2)*2
end with
Next
msgbox "excel rows "&ws.usedrange.rows.count
msgbox "excel columns "&ws.usedrange.columns.count
qtp.open qtp_test
Call local_settings()
res= fire_app()
msgbox "testscript results "&res
Call fire_app()
Call db_clean()
Call time_stamp()
Call send_mail()
Call read_mail()
ie.close
'---------------------------------------------------------------------
Function addins()
a=array("web")
qtp.setactiveaddins a
qtp.visible=true
qtp.launch
End Function
Function global_settings()
with qtp.options.run
.runmode="Fast"
.viewresults=false
.imagecapturefortestresults="Never"
.moviecapturefortestresults="Never"
end with
qtp.folders.removeall
qtp.folders.Add"c:\"
End Function
Function aut()
Set ie=createobject("internetexplorer.application")
ie.visible=true
ie.navigate url
Set aut=ie
End Function
Function local_settings()
with qtp.test.settings.run
.iterationmode="oneIteration"
.disablesmartidentification=true
.objectsynctimeout=10000
end with
qtp.test.settings.resources.libraries.removeall
qtp.test.settings.resources.libraries.add function_lib
For i=1 to qtp.test.actions.count
qtp.test.actions.item(i).objectrepositories.removeall
qtp.test.actions.item(i).objectrepositories.add object_repository
Next
End Function
Function fire_app()
qtp.test.run
fire_app=qtp.test.lastrunresults.status
End Function
Function db_clean()
Set db=createobject("adodb.connection")
db.open"actitime"
Set rs=db.execute("select * from at_user")
msgbox "checking db "&rs(0).value
msgbox "checking db "&rs(1).value
rs.movenext
msgbox "checking db "&rs(0).value
End Function
Function time_stamp()
ts=replace(now,":","_")
ts=replace(ts,"/","_")
wb.saveas "C:\"&ts&".xls"
wb.close
xl.quit
End Function
Function send_mail()
Set ol=createobject("outlook.application")
Set mail=ol.createitem(0)
mail.to="j.t@gmail.com"
mail.cc="j.t@gmail.com"
mail.subject="test_autoation"
mail.body="body"
'mail.attachments.add""
mail.Send
ol.quit
End Function
Function read_mail()
Set ol=createobject("outlook.application")
Set ol_ns=ol.getnamespace("Mapi")
set ol_obj=ol_ns=getdefaultfolder(6)
'msgbox ol_obj.items.count
For each item in ol_obj.items
If item.unread Then
a=item.subject
If a= "test_autoation"Then
msgbox "reading email "&"a o k"
End If
End If
Next
ol.quit
End Function