By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
428,705 Members | 1,301 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 428,705 IT Pros & Developers. It's quick & easy.

Microsoft application center test...oResponse.body parsing

P: n/a
Hello everyone,

I am fairly new to MACT, I am currently trying to parse the
oResponse.Body to retrive a dynamic values...store in an array and then
randomly post those values.

Does anyone have any sample code on how to parse the oResponse.Body?

This is what I have so far but I cannot seem to get the value I'm
trying to pick up.
I have been struguling on getting this values for a couple of days now.

The line of source code I'm trying to pickup displays as follows:
<form name="form2" action="/emobile/l.cfm" method="post">
<input type="hidden" name="params"
value="RAND;3928;P_TYPE;0;MYSTATUS;5;AREA;2;SD;0;S EARCH;Search;"/>

I would like to grab value and store it somewhere.

Thanks in advance.

'--------------------------------------------
' Here I'm posting my random search critieria
' and then it will return a page with the results in a form
' of links. The links area property address'
'

Sub SendRequest9()
Dim oConnection, oRequest, oResponse, oHeaders, strStatusCode
If fEnableDelays = True then Test.Sleep (20051)
Set oConnection = Test.CreateConnection(sSiteName, 80, false)
If (oConnection is Nothing) Then
Test.Trace "Error: Unable to create connection to " & sSiteName
Else
Set oRequest = Test.CreateRequest
oRequest.Path = "/emobile/l.cfm"
oRequest.Verb = "POST"
oRequest.HTTPVersion = "HTTP/1.0"
oRequest.EncodeBody = False
set oHeaders = oRequest.Headers
oHeaders.RemoveAll
oHeaders.Add "Accept", "image/gif, image/x-xbitmap, image/jpeg,
image/pjpeg, application/x-shockwave-flash, application/vnd.ms-excel,
application/vnd.ms-powerpoint, application/msword, */*"
oHeaders.Add "Referer", "http://" & sSiteName &
"/emobile/cr.cfm"
oHeaders.Add "Accept-Language", "en-us"
oHeaders.Add "Content-Type",
"application/x-www-form-urlencoded"
oHeaders.Add "User-Agent", "Mozilla/4.0 (compatible; MSIE 6.0;
Windows NT 5.1; .NET CLR 1.0.3705; .NET CLR 1.1.4322; .NET CLR
2.0.50215)"
'oHeaders.Add "Host", sSiteName
oHeaders.Add "Host", "(automatic)"
oHeaders.Add "Pragma", "no-cache"
oHeaders.Add "Cookie", "(automatic)"
oHeaders.Add "Content-Length", "(automatic)"
' Test.TraceLevel= -1
oRequest.Body = "rand=8833&p_type=" & GetRandomPropertyType &
"mystatus=" & GetRandomStatus & "area=" & GetRandomArea &
"st=&streetnu"
oRequest.Body = oRequest.Body + "m1=&streetnum2=&zip_code=&lp1=" &
GetRandomPrice1 & "lp2=" & GetRandomPrice2 & "br1=" & GetRandomBed1
oRequest.Body = oRequest.Body + "br2="& GetRandomBed2& "ba1=" &
GetRandomBath1 & "ba2=" & GetRandomBath2 &
"sf1=&sf2=&lsz1=&lsz2=&unt1=&unt2"
oRequest.Body = oRequest.Body + "=&sd=0&Search=Search"
Set oResponse = oConnection.Send(oRequest)
If (oResponse is Nothing) Then
Test.Trace "Error: Failed to receive response for URL to "
+ "/emobile/l.cfm"
Else
strStatusCode = oResponse.ResultCode
End If
oConnection.Close
End If
End Sub
'---------------------
' here I am trying to parse the oResponse.body but get
' nothing using the InStr towards the end of the Sub. I also tried
' the code on the sub above right after the If (oResponse Nothing)
' Then
Else
'Begin params parsing

Sub SendRequest10()
Dim oConnection, oRequest, oResponse, oHeaders, strStatusCode
Dim oUser, Pos1, Pos2, sParams
If fEnableDelays = True then Test.Sleep (287)
Set oConnection = Test.CreateConnection(sSiteName, 80, false)
If (oConnection is Nothing) Then
Test.Trace "Error: Unable to create connection to " & sSiteName
Else
Set oRequest = Test.CreateRequest
Set oUser = Test.GetCurrentUser
oRequest.Path = "/emobile/l.cfm"
oRequest.Verb = "GET"
oRequest.HTTPVersion = "HTTP/1.0"
set oHeaders = oRequest.Headers
oHeaders.RemoveAll
oHeaders.Add "Accept", "*/*"
'Test.Trace("**************************" & oUser.Name & "
RETRIEVING RESULTS**************************")
oHeaders.Add "Referer", "http://" & sSiteName &
"/emobile/l.cfm"
oHeaders.Add "Accept-Language", "en-us"
oHeaders.Add "User-Agent", "Mozilla/4.0 (compatible; MSIE 6.0;
Windows NT 5.1; .NET CLR 1.0.3705; .NET CLR 1.1.4322; .NET CLR
2.0.50215)"
'oHeaders.Add "Host", sSiteName
oHeaders.Add "Host", "(automatic)"
oHeaders.Add "Cookie", "(automatic)"
Set oResponse = oConnection.Send(oRequest)
If (oResponse is Nothing) Then
Test.Trace "Error: Failed to receive response for URL to "
+ "/CFIDE/debug/images/topdoc.gif"
Else
'Begin params parsing
If InStr(oResponse.Body, "params") Then
Pos1 = InStr(InStr(oResponse.Body, "params"), oResponse.Body,
"value=")
Pos2 = InStr(Pos1, oResponse.Body, "/>")
sParams = Mid(oResponse.Body, Pos1, Pos2)
Test.Trace "params 2= " & sParams
End If
strStatusCode = oResponse.ResultCode
'Test.Trace "params = " & sParams
End If
oConnection.Close
End If
End Sub

Aug 31 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.