For QTP Scripts & Documents Visit: www.gcreddy.
com
QTP Functions
SUBROUTINES
1) Subroutine to clear the browser cookies and temp files
Sub ClearCookies
OpenBrowser "iexplore.exe", "http://qap.www.realtor.com/"
wait (3)
Browser("Real Estate Listings,").WinToolbar("ToolbarWindow32").Press "&Tools"
Browser("Real Estate Listings,").WinMenu("ContextMenu").Select "Internet Options"
Browser("Real Estate Listings,").Dialog("Internet Options").WinButton("Delete").Click
Browser("Real Estate Listings,").Dialog("Internet Options").Dialog("Delete Browsing
History").WinButton("Delete all").Click
Browser("Real Estate Listings,").Dialog("Internet Options").Dialog("Delete Browsing
History").Dialog("Delete Browsing History").WinButton("Yes").Click
Browser("Real Estate Listings,").Dialog("Internet Options").WinButton("OK").Click
Browser("Real Estate Listings,").Page("Real Estate Listings,").Sync
Browser("Real Estate Listings,").Close
End Sub
Subroutine to create a file to store results of this test
Sub CreateFiles
Set fso = CreateObject("Scripting.FileSystemObject")
Set filetxt = fso.CreateTextFile(mypath, true)
filetxt.WriteLine("<html><font face=Arial
color=blue><h3><b>2Step_1orMoreAcres_Attribute_145_100orMoreAcres  &n
bsp        " ) & Date&"<br>"
filetxt.WriteLine("</b></font></h3><br>")
filetxt.WriteLine("<br><font face=Arial></html>")
For Software Testing Documents visit: ww.gcreddy.net 1
For QTP Scripts & Documents Visit: www.gcreddy.com
filetxt.Close
End Sub
'_______________________________________________________________________
_____________________________________________________________
'Report the results of the test
Sub ReportPass
Const ForReading = 1, ForWriting = 2, ForAppending = 8
Set fso = CreateObject("Scripting.FileSystemObject")
Set filetxt = fso.OpenTextFile(mypath, ForAppending, True)
filetxt.WriteLine(val &"<br>")
filetxt.WriteLine("<br>")
End Sub
'_______________________________________________________________________
_____________________________________________________________
'Report the results of the test
Sub ReportFail
Const ForReading = 1, ForWriting = 2, ForAppending = 8
Set fso = CreateObject("Scripting.FileSystemObject")
Set filetxt = fso.OpenTextFile(mypath, ForAppending, True)
filetxt.WriteLine("<font color=red>"&val&"<br>")
filetxt.WriteLine("URL = " & strTargetURL &"</font><br>")
filetxt.WriteLine("<br>")
End Sub
'_______________________________________________________________________
_____________________________________________________________
For Software Testing Documents visit: ww.gcreddy.net 2
For QTP Scripts & Documents Visit: www.gcreddy.com
'Update execution result in dbo.Automation_Run table
Sub UpdateRun
Set dbConnection = CreateObject("ADODB.Connection")
dbConnection.Open("Driver={SQL
Server};Server=TAZ02MON901;Database=Automation")
sqlUpdateRun = "EXEC dbo.sp_AUTOMATION_RUNS_MOD @SCRIPTID = '186',
@RUNSTATUSID = " & intRunStatusID
dbConnection.Execute(sqlUpdateRun)
dbConnection.Close
Set dbConnection = Nothing
End Sub
'_______________________________________________________________________
_____________________________________________________________
'Subroutine to send an email notification of test results
Sub SendMail
If msgnum = 0 Then
msgstr = "2Step_1orMoreAcres_Attribute_145_100orMoreAcres Test
Results:" &vbcrLf &"All Test Cases Passed "
Else
msgstr =
"2Step_1orMoreAcres_Attribute_145_100orMoreAcres Test Results:" &vbcrLf &"One or
more of the Test Cases Failed." &vbcrLf &"See attachment for details."
End If
Set objMessage = CreateObject("CDO.Message")
objMessage.Subject = "~2Step_1orMoreAcres_Attribute_145_100orMoreAcres"
objMessage.From = "[email protected]"
For Software Testing Documents visit: ww.gcreddy.net 3
For QTP Scripts & Documents Visit: www.gcreddy.com
objMessage.To = "
[email protected]"
[email protected]"
'objMessage.To = "[email protected]"
objMessage.TextBody = msgstr
doc = mypath 'Local
objMessage.AddAttachment (doc)
'_________________________________________________________________
_______________________________________________________________
'This section provides the configuration information for the remote SMTP server.
objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configu
ration/sendusing") = 2
'Name or IP of Remote SMTP Server
'smtpServer = "apmx01.homestore.com"
smtpServer = "smtp.phx.move.com"
objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configu
ration/smtpserver") = (smtpServer)
'Type of authentication, NONE, Basic (Base64 encoded), NTLM
objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configu
ration/smtpauthenticate") = cdoNONE
'Your UserID on the SMTP server
'objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/config
uration/sendusername") = "youruserid"
'Your password on the SMTP server
'objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/config
uration/sendpassword") = "yourpassword"
'Server port (typically 25)
For Software Testing Documents visit: ww.gcreddy.net 4
For QTP Scripts & Documents Visit: www.gcreddy.com
objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configu
ration/smtpserverport") = 25
'Use SSL for the connection (False or True)
objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configu
ration/smtpusessl") = False
'Connection Timeout in seconds (the maximum time CDO will try to establish a
connection to the SMTP server)
objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configu
ration/smtpconnectiontimeout") = 60
objMessage.Configuration.Fields.Update
'_________________________________________________________________
_______________________________________________________________
'Send the notification
objMessage.Send
End Sub
'_______________________________________________________________________
_____________________________________________________________
'Subroutine to send an email notification of test results to the Realtor group
Sub SendMail2
If msgnum = 0 Then
msgstr = "2Step_1orMoreAcres_Attribute_145_100orMoreAcres Test
Results:" &vbcrLf &"All Test Cases Passed "
Else
msgstr =
"2Step_1orMoreAcres_Attribute_145_100orMoreAcres Test Results:" &vbcrLf &"One or
more of the Test Cases Failed." &vbcrLf &"See attachment for details."
End If
Set objMessage = CreateObject("CDO.Message")
objMessage.Subject = "~2Step_1orMoreAcres_Attribute_145_100orMoreAcres"
objMessage.From = "[email protected]"
For Software Testing Documents visit: ww.gcreddy.net 5
For QTP Scripts & Documents Visit: www.gcreddy.com
'objMessage.To = "[email protected]"
objMessage.To = "[email protected]"
objMessage.TextBody = msgstr
doc = mypath 'Local
objMessage.AddAttachment (doc)
'_________________________________________________________________
_______________________________________________________________
'This section provides the configuration information for the remote SMTP server.
objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configu
ration/sendusing") = 2
'Name or IP of Remote SMTP Server
'smtpServer = "apmx01.homestore.com"
smtpServer = "smtp.phx.move.com"
objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configu
ration/smtpserver") = (smtpServer)
'Type of authentication, NONE, Basic (Base64 encoded), NTLM
objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configu
ration/smtpauthenticate") = cdoNONE
'Your UserID on the SMTP server
'objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/config
uration/sendusername") = "youruserid"
'Your password on the SMTP server
'objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/config
uration/sendpassword") = "yourpassword"
'Server port (typically 25)
objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configu
ration/smtpserverport") = 25
'Use SSL for the connection (False or True)
For Software Testing Documents visit: ww.gcreddy.net 6
For QTP Scripts & Documents Visit: www.gcreddy.com
objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configu
ration/smtpusessl") = False
'Connection Timeout in seconds (the maximum time CDO will try to establish a
connection to the SMTP server)
objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configu
ration/smtpconnectiontimeout") = 60
objMessage.Configuration.Fields.Update
'_________________________________________________________________
_______________________________________________________________
'Send the notification
objMessage.Send
End Sub
'_______________________________________________________________________
_____________________________________________________________
'Subroutine to append an Excel file
Sub AppendXL
Set ExcelObj = CreateObject("Excel.Application")
ExcelObj.Visible = True
Set wb = ExcelObj.Workbooks.Open (strDataSheet)
r=1
Do Until Len(ExcelObj.Cells(r, 1).Value) = 0
r=r+1
Loop
ExcelObj.Cells(r, 1).Value = strTestName
ExcelObj.Cells(r, 2).Value = strView
ExcelObj.Cells(r, 3).Value = listingid
ExcelObj.Cells(r, 4).Value = postalcode
For Software Testing Documents visit: ww.gcreddy.net 7
For QTP Scripts & Documents Visit: www.gcreddy.com
ExcelObj.Cells(r, 5).Value = marketingtypeid
ExcelObj.Cells(r, 6).Value = listingtypeid
ExcelObj.Cells(r, 7).Value = bedrooms
ExcelObj.Cells(r, 8).Value = bathrooms
ExcelObj.Cells(r, 9).Value = price
ExcelObj.Cells(r, 10).Value = address
ExcelObj.Cells(r, 11).Value = city
ExcelObj.Cells(r, 12).Value = state
ExcelObj.Cells(r, 13).Value = strDate
ExcelObj.Cells(r, 14).Value = strStartTime
ExcelObj.Cells(r, 15).Value = strEndTime
ExcelObj.DisplayAlerts = False
ExcelObj.Save
ExcelObj.Quit
Set ExcelObj = Nothing
End Sub
'_______________________________________________________________________
_____________________________________________________________
'Subroutine to check the list view
Sub ListCheck
For Counter=0 to strResults-1
strTextDesc=childObjs(Counter).GetROProperty("outerhtml")
'msgbox strTextDesc
ListingCheck = InStr (strTextDesc,listingid)
'msgbox ListingCheck
For Software Testing Documents visit: ww.gcreddy.net 8
For QTP Scripts & Documents Visit: www.gcreddy.com
If ListingCheck <> 0 Then
'msgbox "Pass"
strFail= 0
Exit For
Else
'msgbox "Fail"
strFail = 1
End If
Next
End Sub
'_______________________________________________________________________
_____________________________________________________________
'Subroutine to check the galery view
Sub GalleryCheck
For Counter=0 to strResults-1
strTextDesc=childObjs(Counter).GetROProperty("outerhtml")
'msgbox strTextDesc
ListingCheck = InStr (strTextDesc,listingid)
'msgbox ListingCheck
If ListingCheck <> 0 Then
'msgbox "Pass"
strFail= 0
Exit For
Else
'msgbox "Fail"
For Software Testing Documents visit: ww.gcreddy.net 9
For QTP Scripts & Documents Visit: www.gcreddy.com
strFail = 1
End If
Next
End Sub
'_______________________________________________________________________
_____________________________________________________________
' Subroutine to check the map view
Sub Mapcheck
strPnum = 0
For Counter=0 to strResults-1
strPropertyDesc = childObjs(strPnum).GetROProperty("outerhtml")
'strPropertyDesc=Browser("Real Estate Listings,_5").Page("55116 real estate &
55116").Image("Community Photo").GetROProperty("outerhtml")
'msgbox strPropertyDesc
ListingCheck = InStr (strPropertyDesc,listingid)
'msgbox ListingCheck
If ListingCheck <> 0 Then
'msgbox "Pass"
strFail= 0
Exit For
Else
'msgbox "Fail"
strFail = 1
End If
'
strPnum =strPnum+1
For Software Testing Documents visit: ww.gcreddy.net 10
For QTP Scripts & Documents Visit: www.gcreddy.com
Next
End Sub
'_______________________________________________________________________
_____________________________________________________________
For QTP Information:
www.gcreddy.com
For Manual Testing:
www.gcreddy.net
For Software Testing Documents visit: ww.gcreddy.net 11