For QTP Scripts & Documents Visit: www.gcreddy.
com
A Sample QTP Real-time Test Script
########################################################
########################################################
####################
'### Test Name: 2Step_1orMoreAcres_Attribute_145_100orMoreAcres
'# ## Created by: Sam Harris
'### Purpose: Verify the 145 Lot Size is 100 or More Acres atttribute in the 1 or More
Acres Scenario
'### Creation Date: 1/11/2010
'#######################################################
########################################################
#####################
'=======================
' SETUP
'=======================
'_______________________________________________________________________
_____________________________________________________________
Dim objNet
Dim strInfo
'_______________________________________________________________________
_____________________________________________________________
'Set the initial value of the variables
i=1
msgnum = 0
strFail = 1
strTestName = "2Step_1orMoreAcres_Attribute_145_100orMoreAcres"
'_______________________________________________________________________
_____________________________________________________________
For Software Testing Documents visit: ww.gcreddy.net 1
For QTP Scripts & Documents Visit: www.gcreddy.com
'Function to open a brower and go to a specified URL
Function OpenBrowser (browser, URL)
systemUtil.Run browser, URL
End Function
'_______________________________________________________________________
_____________________________________________________________
'Get Computer Name
set wshnetwork=createobject("wscript.network")
scomputername=wshnetwork.computername
set wshnetwork=nothing
strServ = scomputername
'msgbox strServ
'_______________________________________________________________________
_____________________________________________________________
'Turn off the report filter
CurrentMode = Reporter.Filter
Reporter.Filter = rfDisableAll
'_______________________________________________________________________
_____________________________________________________________
'Get username from the local box
Set objNet = CreateObject("WScript.NetWork")
strInfo = objNet.UserName
'msgbox strInfo
'_______________________________________________________________________
_____________________________________________________________
'Create a unique name for the results file each time the test is executed.
For Software Testing Documents visit: ww.gcreddy.net 2
For QTP Scripts & Documents Visit: www.gcreddy.com
mypath =
"\\taz02mon901\Mercury\QTP_Test_Results\2Step_1orMoreAcres_Attribute_145_100orMo
reAcres.html"
Call CreateFiles()
'_______________________________________________________________________
_____________________________________________________________
' Set Excel File to be appenced
strDataSheet = "\\taz02mon901\Mercury\Mercury_QTP_Test\Realtor\2-
Step\2STEP_ATTRIBUTES_FAILURE_LOG_QA.xls"
'_______________________________________________________________________
_____________________________________________________________
'Clear the cookies and temp files
'Call ClearCookies
'_______________________________________________________________________
_____________________________________________________________
'=======================
' MAIN
'=======================
'_______________________________________________________________________
_____________________________________________________________
'Database query
' Connect to the Realtor database
Set dbconn = CreateObject("ADODB.Connection")
Set recordset = CreateObject("ADODB.recordset")
'MS SQL Server DSNless connection
'dbconn.Open("Driver={SQL Server};Server=TAZ02SQL832 ;Database=XProperty
;Uid=admin;Pwd=admin")
dbconn.Open("Driver={SQL Server};Server=TAZ02SQL832;Database=XProperty")
For Software Testing Documents visit: ww.gcreddy.net 3
For QTP Scripts & Documents Visit: www.gcreddy.com
dbconn.commandTimeout = 300
' Specify the query
sql = "select top 1
l.listingid,l.postalcode,l.marketingtypeid,l.listingtypeid,l.bedrooms,l.bathrooms,l.listingsqft,
l.price,l.address,l.city,l.state,l.createdate,l.geoapproximation from xproperty.dbo.listing
(nolock) l join xproperty.dbo.LISTING_ATTRIBUTE (nolock) la1 on l.listingid = la1.listingid
left join xproperty.dbo.LISTING_ATTRIBUTE (nolock) la2 on l.listingid = la2.listingid and
la2.attributeid in (144,146,147,150,152,154,159,161,166) where l.status = 'a' and
l.agentid is not null and l.postalcode is not null and l.postalcode <> '' and l.country = 'usa'
and la1.attributeid = 145 and l.geoapproximation = 1 and l.DataSourceID not in (select
datasourceid from xproperty.dbo.DATA_SOURCE_ATTRIBUTE where attributeid in (27,31))
and la2.ListingID is null and l.createdate < getdate() - 2 order by l.createdate desc"
' Set the recordset cursor type
recordset.CursorType = 0
' Execute the query
recordset.Open sql, dbconn
listingid = recordset.Fields("listingid")&""
listingid = Trim(listingid)'
'msgbox listingid
postalcode = recordset.Fields("postalcode")&""
'msgbox postalcode
marketingtypeid = recordset.Fields("marketingtypeid")&""
'msgbox marketingtypeid
listingtypeid = recordset.Fields("listingtypeid")&""
'msgbox listingtypeid
bedrooms = recordset.Fields("bedrooms")&""
'msgbox bedrooms
bathrooms = recordset.Fields("bathrooms")&""
'msgbox bathrooms
listingsqft = recordset.Fields("listingsqft")&""
For Software Testing Documents visit: ww.gcreddy.net 4
For QTP Scripts & Documents Visit: www.gcreddy.com
'msgbox listingsqft
price = recordset.Fields("price")&""
'msgbox price
address = recordset.Fields("address")&""
'msgbox address
city = recordset.Fields("city")&""
'msgbox city
state = recordset.Fields("state")&""
'msgbox state
createdate = recordset.Fields("createdate")&""
'msgbox createdate
If bedrooms = "" Then
'Do Nothing
Else
If bedrooms >5 Then
bedrooms = 5
End If
End If
bathrooms = fix(bathrooms)
If bathrooms = "" Then
'Do Nothing
Else
If bedrooms >5 Then
bedrooms = 5
End If
For Software Testing Documents visit: ww.gcreddy.net 5
For QTP Scripts & Documents Visit: www.gcreddy.com
End If
If listingtypeid = 6 Then
bedrooms = ""
bathrooms = ""
End If
'_______________________________________________________________________
_____________________________________________________________
' Date and Start Time of the test run
strDate = date
strStartTime = time
'_______________________________________________________________________
_____________________________________________________________
'Open a browser to the REALTOR.com homepage
OpenBrowser "iexplore.exe", "http://qap.www.realtor.com/"
wait (3)
'_______________________________________________________________________
_____________________________________________________________
'Find the listing
'Browser("Real Estate Listings,").WinEdit("Edit").Check CheckPoint("Edit_8")
Browser("Real Estate Listings,").Navigate ("http://qap.www.realtor.com/prop/"&listingid)
Browser("Real Estate Listings,").Sync
strView = "LDP"
'_______________________________________________________________________
_____________________________________________________________
'Check for the text office on the LDP
'Browser("Real Estate Listings,_5").Page("2275 Youngman Ave
Unit:").WebElement("Property Information for").Check CheckPoint("Property Information
for 2275 Youngman Ave Unit: 108W Save Listing Property FeaturesCondo/Townhome/Row
Home/Co-OpStatus: Active Area: SP-Highland Area County: RAMSEYYear Built: 1980 1
For Software Testing Documents visit: ww.gcreddy.net 6
For QTP Scripts & Documents Visit: www.gcreddy.com
total bedroom(s) 2 total bath(s) Approximately 1130 sq. ft.Style: High Rise (4+ Levels)
Office 1 car garage School District: St. Paul Exterior FeaturesHeated garage Listing
InformationRefreshed at 9:35 AM PT (19 days ago)Added on Jun 29, 2004 (1940 days
ago) To access this page directly, usehttp://qap.www.realtor.com/realestateandhomes-
detail/2275-Youngman-Ave-Unit-108W_St-Paul_MN_55116_1038274619 This listing is
brokered byEdina Realty, Inc.Office: (651)698-2434")
strPropInfo = Browser("Real Estate Listings,_5").Page("2275 Youngman Ave
Unit:").WebElement("Property Information for").GetROProperty("innertext")
'msgbox strPropInfo
strGarageCheck = Instr(strPropInfo, "Lot size is 100 or more acres")
'msgbox strGarageCheck
If strGarageCheck <> 0 Then
'msgbox "Pass"
Else
'msgbox "Fail"
strEndTime = time
Call AppendXL
msgnum = msgnum+1
Browser("Real Estate Listings,_5").Page("2275 Youngman Ave
Unit:").Sync
Browser("Real Estate Listings,_5").Close
Call SendMail
ExitTest
End If
'_______________________________________________________________________
_____________________________________________________________
'Close the browser
Browser("Real Estate Listings,_5").Page("2275 Youngman Ave Unit:").Sync
Browser("Real Estate Listings,_5").Close
For Software Testing Documents visit: ww.gcreddy.net 7
For QTP Scripts & Documents Visit: www.gcreddy.com
'_______________________________________________________________________
_____________________________________________________________
'Open a browser to the REALTOR.com homepage
OpenBrowser "iexplore.exe", "http://qap.www.realtor.com/"
wait (3)
'_______________________________________________________________________
____________________________________________________________
Browser("Real Estate Listings,_5").Page("Real Estate
Listings,").WebEdit("srchHomeLocation").Set postalcode
Browser("Real Estate Listings,_5").Page("Real Estate
Listings,").WebRadioGroup("ctl00$cphC$MainSearch$ccBuyRen").Select marketingtypeid
Browser("Real Estate Listings,_5").Page("Real Estate Listings,").WebElement("More
Search Options").FireEvent "onmouseover"
Browser("Real Estate Listings,_5").Page("Real Estate Listings,").WebElement("More
Search Options").Click
Browser("Real Estate Listings,_5").Page("Real Estate Listings,").WebEdit("tbMinPrice").Set
price
Browser("Real Estate Listings,_5").Page("Real Estate
Listings,").WebEdit("tbMaxPrice").Set price
Browser("Real Estate Listings,_5").Page("Real Estate
Listings,").WebList("ctl00$cphC$AdvancedSearchPage$_2").Select bedrooms&"+"
Browser("Real Estate Listings,_5").Page("Real Estate
Listings,").WebList("ctl00$cphC$AdvancedSearchPage$_3").Select bathrooms&"+"
If marketingtypeid = 2 Then
'Browser("Real Estate Listings,_5").Page("Real Estate
Listings,").WebElement("WebElement").FireEvent "onmouseover"
Browser("Real Estate Listings,_5").Page("Real Estate
Listings,").WebRadioGroup("ctl00$cphC$AdvancedSearchPage$").FireEvent
"onmouseover"
Browser("Real Estate Listings,_5").Page("Real Estate
Listings,").WebRadioGroup("ctl00$cphC$AdvancedSearchPage$").Select "2"
wait (3)
For Software Testing Documents visit: ww.gcreddy.net 8
For QTP Scripts & Documents Visit: www.gcreddy.com
End If
If listingtypeid = 1 Then
Browser("Real Estate Listings,_5").Page("Real Estate
Listings,").WebCheckBox("ctl00$cphC$AdvancedSearchPage$").Set "ON"
Browser("Real Estate Listings,_5").Page("Real Estate
Listings,").WebCheckBox("ctl00$cphC$AdvancedSearchPage$_2").Set "OFF"
Browser("Real Estate Listings,_5").Page("Real Estate
Listings,").WebCheckBox("ctl00$cphC$AdvancedSearchPage$_4").Set "OFF"
Browser("Real Estate Listings,_5").Page("Real Estate
Listings,").WebCheckBox("ctl00$cphC$AdvancedSearchPage$_5").Set "OFF"
Browser("Real Estate Listings,_5").Page("Real Estate
Listings,").WebCheckBox("ctl00$cphC$AdvancedSearchPage$_6").Set "OFF"
Browser("Real Estate Listings,_5").Page("Real Estate
Listings,").WebCheckBox("ctl00$cphC$AdvancedSearchPage$_7").Set "OFF"
ElseIf listingtypeid = 2 Then
Browser("Real Estate Listings,_5").Page("Real Estate
Listings,").WebCheckBox("ctl00$cphC$AdvancedSearchPage$").Set "OFF"
Browser("Real Estate Listings,_5").Page("Real Estate
Listings,").WebCheckBox("ctl00$cphC$AdvancedSearchPage$_2").Set "ON"
Browser("Real Estate Listings,_5").Page("Real Estate
Listings,").WebCheckBox("ctl00$cphC$AdvancedSearchPage$_4").Set "OFF"
Browser("Real Estate Listings,_5").Page("Real Estate
Listings,").WebCheckBox("ctl00$cphC$AdvancedSearchPage$_5").Set "OFF"
Browser("Real Estate Listings,_5").Page("Real Estate
Listings,").WebCheckBox("ctl00$cphC$AdvancedSearchPage$_6").Set "OFF"
Browser("Real Estate Listings,_5").Page("Real Estate
Listings,").WebCheckBox("ctl00$cphC$AdvancedSearchPage$_7").Set "OFF"
ElseIf listingtypeid = 4 Then
Browser("Real Estate Listings,_5").Page("Real Estate
Listings,").WebCheckBox("ctl00$cphC$AdvancedSearchPage$").Set "OFF"
Browser("Real Estate Listings,_5").Page("Real Estate
Listings,").WebCheckBox("ctl00$cphC$AdvancedSearchPage$_2").Set "OFF"
For Software Testing Documents visit: ww.gcreddy.net 9
For QTP Scripts & Documents Visit: www.gcreddy.com
Browser("Real Estate Listings,_5").Page("Real Estate
Listings,").WebCheckBox("ctl00$cphC$AdvancedSearchPage$_4").Set "ON"
Browser("Real Estate Listings,_5").Page("Real Estate
Listings,").WebCheckBox("ctl00$cphC$AdvancedSearchPage$_5").Set "OFF"
Browser("Real Estate Listings,_5").Page("Real Estate
Listings,").WebCheckBox("ctl00$cphC$AdvancedSearchPage$_6").Set "OFF"
Browser("Real Estate Listings,_5").Page("Real Estate
Listings,").WebCheckBox("ctl00$cphC$AdvancedSearchPage$_7").Set "OFF"
ElseIf listingtypeid = 3 Then
Browser("Real Estate Listings,_5").Page("Real Estate
Listings,").WebCheckBox("ctl00$cphC$AdvancedSearchPage$").Set "OFF"
Browser("Real Estate Listings,_5").Page("Real Estate
Listings,").WebCheckBox("ctl00$cphC$AdvancedSearchPage$_2").Set "OFF"
Browser("Real Estate Listings,_5").Page("Real Estate
Listings,").WebCheckBox("ctl00$cphC$AdvancedSearchPage$_4").Set "OFF"
Browser("Real Estate Listings,_5").Page("Real Estate
Listings,").WebCheckBox("ctl00$cphC$AdvancedSearchPage$_5").Set "ON"
Browser("Real Estate Listings,_5").Page("Real Estate
Listings,").WebCheckBox("ctl00$cphC$AdvancedSearchPage$_6").Set "OFF"
Browser("Real Estate Listings,_5").Page("Real Estate
Listings,").WebCheckBox("ctl00$cphC$AdvancedSearchPage$_7").Set "OFF"
ElseIf listingtypeid = 5 Then
Browser("Real Estate Listings,_5").Page("Real Estate
Listings,").WebCheckBox("ctl00$cphC$AdvancedSearchPage$").Set "OFF"
Browser("Real Estate Listings,_5").Page("Real Estate
Listings,").WebCheckBox("ctl00$cphC$AdvancedSearchPage$_2").Set "OFF"
Browser("Real Estate Listings,_5").Page("Real Estate
Listings,").WebCheckBox("ctl00$cphC$AdvancedSearchPage$_4").Set "OFF"
Browser("Real Estate Listings,_5").Page("Real Estate
Listings,").WebCheckBox("ctl00$cphC$AdvancedSearchPage$_5").Set "OFF"
Browser("Real Estate Listings,_5").Page("Real Estate
Listings,").WebCheckBox("ctl00$cphC$AdvancedSearchPage$_6").Set "ON"
For Software Testing Documents visit: ww.gcreddy.net 10
For QTP Scripts & Documents Visit: www.gcreddy.com
Browser("Real Estate Listings,_5").Page("Real Estate
Listings,").WebCheckBox("ctl00$cphC$AdvancedSearchPage$_7").Set "OFF"
ElseIf listingtypeid = 6 Then
Browser("Real Estate Listings,_5").Page("Real Estate
Listings,").WebCheckBox("ctl00$cphC$AdvancedSearchPage$").Set "OFF"
Browser("Real Estate Listings,_5").Page("Real Estate
Listings,").WebCheckBox("ctl00$cphC$AdvancedSearchPage$_2").Set "OFF"
Browser("Real Estate Listings,_5").Page("Real Estate
Listings,").WebCheckBox("ctl00$cphC$AdvancedSearchPage$_4").Set "OFF"
Browser("Real Estate Listings,_5").Page("Real Estate
Listings,").WebCheckBox("ctl00$cphC$AdvancedSearchPage$_5").Set "OFF"
Browser("Real Estate Listings,_5").Page("Real Estate
Listings,").WebCheckBox("ctl00$cphC$AdvancedSearchPage$_6").Set "OFF"
Browser("Real Estate Listings,_5").Page("Real Estate
Listings,").WebCheckBox("ctl00$cphC$AdvancedSearchPage$_7").Set "ON"
End If
Browser("Real Estate Listings,").Page("Real Estate Listings,_3").Link("Lot &
Community").FireEvent "onmouseover"
Browser("Real Estate Listings,").Page("Real Estate Listings,_3").Link("Lot &
Community").Click
Browser("Real Estate Listings,_5").Page("Real Estate
Listings,").WebList("ctl00$cphC$AdvancedSearchPage$_5").FireEvent "onmouseover"
Browser("Real Estate Listings,_5").Page("Real Estate
Listings,").WebList("ctl00$cphC$AdvancedSearchPage$_5").Click
Browser("Real Estate Listings,_5").Page("Real Estate
Listings,").WebList("ctl00$cphC$AdvancedSearchPage$_5").Select "1 or More Acres"
Browser("Real Estate Listings,_5").Page("Real Estate Listings,").Link("Search").Click
Browser("Real Estate Listings,_5").Sync
'_______________________________________________________________________
____________________________________________________________
'Select Listview
For Software Testing Documents visit: ww.gcreddy.net 11
For QTP Scripts & Documents Visit: www.gcreddy.com
Browser("Real Estate Listings,_5").Page("55116 real estate &
55116").WebElement("WebElement_2").Click
strView = "List"
Set odesc=description.Create()
odesc("micclass").value="WebElement"
odesc("html tag").value="DIV"
odesc("class").value="listingData"
Set childObjs= Browser("Real Estate Listings,").Page("55116 real estate &
55116").ChildObjects(odesc)
strResults = childObjs.count
'msgbox strResults
If strResults <> 0 Then
Call Listcheck
Else
strFail = 1
End If
If strFail= 0 Then
'Do Nothing
Else
strEndTime = time
Call AppendXL
msgnum = msgnum+1
End If
'_______________________________________________________________________
____________________________________________________________
'Select Galleryview
For Software Testing Documents visit: ww.gcreddy.net 12
For QTP Scripts & Documents Visit: www.gcreddy.com
Browser("Real Estate Listings,_5").Page("55116 real estate &
55116").WebElement("WebElement_4").Click
strView = "Gallery"
Set odesc=description.Create()
odesc("micclass").value="WebElement"
odesc("html tag").value="DIV"
odesc("class").value="listingData"
Set childObjs= Browser("Real Estate Listings,").Page("55116 real estate &
55116").ChildObjects(odesc)
strResults = childObjs.count
'msgbox strResults
If strResults <> 0 Then
Call Gallerycheck
Else
strFail = 1
End If
If strFail= 0 Then
'Do Nothing
Else
strEndTime = time
Call AppendXL
msgnum = msgnum+1
End If
'_______________________________________________________________________
____________________________________________________________
'Select Mapview
For Software Testing Documents visit: ww.gcreddy.net 13
For QTP Scripts & Documents Visit: www.gcreddy.com
Browser("Real Estate Listings,").Page("55116 real estate &
55116").Image("REALTOR.com® - Official").Click
Browser("Real Estate Listings,").Sync
Browser("Real Estate Listings,").Page("Real Estate Listings,_3").WebElement("More
Search Options").Click
If marketingtypeid = 2 Then
'Browser("Real Estate Listings,_5").Page("Real Estate
Listings,").WebElement("WebElement").FireEvent "onmouseover"
Browser("Real Estate Listings,_5").Page("Real Estate
Listings,").WebRadioGroup("ctl00$cphC$AdvancedSearchPage$").FireEvent
"onmouseover"
Browser("Real Estate Listings,_5").Page("Real Estate
Listings,").WebRadioGroup("ctl00$cphC$AdvancedSearchPage$").Select "2"
wait (3)
End If
Browser("Real Estate Listings,").Page("Real Estate Listings,_3").Link("Display
Options").Click
Browser("Real Estate Listings,").Page("Real Estate
Listings,_3").WebRadioGroup("ccViewResults").Select "map"
Browser("Real Estate Listings,").Page("Real Estate Listings,_3").Link("Search").Click
Browser("Real Estate Listings,").Sync
wait (10)
strView = "Map"
'Browser("Real Estate Listings,").Page("55116 real estate &
55116").WebElement("WebElement_3").Check CheckPoint("WebElement_2")
Set odesc=description.Create()
odesc("micclass").value="WebElement"
odesc("html tag").value="DIV"
odesc("class").value="listingData"
For Software Testing Documents visit: ww.gcreddy.net 14
For QTP Scripts & Documents Visit: www.gcreddy.com
Set childObjs= Browser("Real Estate Listings,").Page("55116 real estate &
55116").ChildObjects(odesc)
strResults = childObjs.count
'msgbox strResults
If strResults <> 0 Then
Call Mapcheck
Else
strFail = 1
End If
If strFail= 0 Then
'Do Nothing
Else
strEndTime = time
Call AppendXL
msgnum = msgnum+1
End If
'_______________________________________________________________________
_____________________________________________________________
'Close the browser
Browser("Real Estate Listings,_5").Page("2275 Youngman Ave Unit:").Sync
Browser("Real Estate Listings,_5").Close
'_______________________________________________________________________
_____________________________________________________________
If msgnum = 0 Then
intRunStatusID = 1
else
For Software Testing Documents visit: ww.gcreddy.net 15
For QTP Scripts & Documents Visit: www.gcreddy.com
intRunStatusID = 0
End If
'_______________________________________________________________________
_____________________________________________________________
'Test Run End Time
strEndTime = time
'_______________________________________________________________________
_____________________________________________________________
'Call UpdateRun
'_______________________________________________________________________
_____________________________________________________________
'Determine which email sub to use based on Pass or Fail
If intRunStatusID = 1 Then
Call SendMail
else
Call SendMail
End If
For QTP Information:
www.gcreddy.com
For Manual Testing:
www.gcreddy.net
For Software Testing Documents visit: ww.gcreddy.net 16