This document contains a QTP script for testing attributes on real estate listings. The script:
1. Connects to a database to retrieve listing details for testing.
2. Opens a browser and navigates to a listing to check if its property information includes "Lot size is 100 or more acres".
3. If not found, the test fails and results are appended to an Excel file.
4. The browser is then used to search for listings matching the retrieved criteria to verify attributes are set correctly.
1. For more QTP Real time scripts, visit www.ramupalanki.com
QTP Scripts
########################################################
########################################################
####################
'### 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
www.ramupalanki.com
2. For more QTP Real time scripts, visit www.ramupalanki.com
'#######################################################
########################################################
#####################
'=======================
' SETUP
'=======================
'_______________________________________________________________________
_____________________________________________________________
Dim objNet
Dim strInfo
'_______________________________________________________________________
_____________________________________________________________
'Set the initial value of the variables
i=1
msgnum = 0
strFail = 1
strTestName = "2Step_1orMoreAcres_Attribute_145_100orMoreAcres"
'_______________________________________________________________________
_____________________________________________________________
'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")
www.ramupalanki.com
3. For more QTP Real time scripts, visit www.ramupalanki.com
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.
mypath =
"taz02mon901MercuryQTP_Test_Results2Step_1orMoreAcres_Attribute_145_100orMo
reAcres.html"
Call CreateFiles()
'_______________________________________________________________________
_____________________________________________________________
' Set Excel File to be appenced
strDataSheet = "taz02mon901MercuryMercury_QTP_TestRealtor2-
Step2STEP_ATTRIBUTES_FAILURE_LOG_QA.xls"
'_______________________________________________________________________
_____________________________________________________________
www.ramupalanki.com
4. For more QTP Real time scripts, visit www.ramupalanki.com
'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")
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
www.ramupalanki.com
6. For more QTP Real time scripts, visit www.ramupalanki.com
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
End If
If listingtypeid = 6 Then
bedrooms = ""
bathrooms = ""
End If
'_______________________________________________________________________
_____________________________________________________________
www.ramupalanki.com
7. For more QTP Real time scripts, visit www.ramupalanki.com
' 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
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
www.ramupalanki.com
8. For more QTP Real time scripts, visit www.ramupalanki.com
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
'_______________________________________________________________________
_____________________________________________________________
'Open a browser to the REALTOR.com homepage
OpenBrowser "iexplore.exe", "http://qap.www.realtor.com/"
wait (3)
'_______________________________________________________________________
____________________________________________________________
www.ramupalanki.com
13. For more QTP Real time scripts, visit www.ramupalanki.com
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
Browser("Real Estate Listings,_5").Page("55116 real estate &
55116").WebElement("WebElement_4").Click
strView = "Gallery"
Set odesc=description.Create()
odesc("micclass").value="WebElement"
www.ramupalanki.com
14. For more QTP Real time scripts, visit www.ramupalanki.com
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
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
www.ramupalanki.com
15. For more QTP Real time scripts, visit www.ramupalanki.com
'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"
Set childObjs= Browser("Real Estate Listings,").Page("55116 real estate &
55116").ChildObjects(odesc)
strResults = childObjs.count
'msgbox strResults
If strResults <> 0 Then
Call Mapcheck
www.ramupalanki.com
16. For more QTP Real time scripts, visit www.ramupalanki.com
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
intRunStatusID = 0
End If
'_______________________________________________________________________
_____________________________________________________________
'Test Run End Time
strEndTime = time
www.ramupalanki.com
17. For more QTP Real time scripts, visit www.ramupalanki.com
'_______________________________________________________________________
_____________________________________________________________
'Call UpdateRun
'_______________________________________________________________________
_____________________________________________________________
'Determine which email sub to use based on Pass or Fail
If intRunStatusID = 1 Then
Call SendMail
else
Call SendMail
End If
www.ramupalanki.com