How to get http request logs
Posted: Mon Sep 05, 2011 9:02 am
Is it possible to get all httprequests of a browser
Eg: we have opened the browser, navigated to google.com, searched for a string, clicked on any link and I got some error
Now I want to track all httprequests from opening browser
We have been using fiddler, but our client wants this to be done by ranorex (so that when particular testcase fails it can send all session details also)
I have tried below with no success
public void httprequests()
{
string _url = repo.WebDocumentEzprints_ecommerce.Self.PageUrl.ToLower();
Uri _uri = new Uri(_url);
HttpWebRequest lWebRequest = (HttpWebRequest) WebRequest.Create(_uri);
HttpWebResponse lWebResponse = (HttpWebResponse)
lWebRequest.GetResponse();
//StreamReader lResponseStream = new StreamReader();
Encoding encode = Encoding.GetEncoding("utf-8");
//StreamReader(lWebResponse.GetResponseStream(),encode);
Stream receiveStream = lWebResponse.GetResponseStream();
//StreamReader reasstream = new StreamReader(receiveStream,encode);
StreamReader readStream = new StreamReader( receiveStream, encode );
Console.WriteLine("\r\nResponse stream received.");
Char[] read = new Char[256];
// Reads 256 characters at a time.
int count = readStream.Read( read, 0, 256 );
Console.WriteLine("HTML...\r\n");
while (count > 0)
{
// Dumps the 256 characters on a string and displays the string to the console.
String str = new String(read, 0, count);
Console.Write(str);
count = readStream.Read(read, 0, 256);
}
Console.WriteLine("");
lWebRequest = null;
lWebResponse.Close();
//lResponseStream.Close();
}
it is giving me th xml in viewsource.
Any information on this will be very helpful
Thanks,
Abhigna
Eg: we have opened the browser, navigated to google.com, searched for a string, clicked on any link and I got some error
Now I want to track all httprequests from opening browser
We have been using fiddler, but our client wants this to be done by ranorex (so that when particular testcase fails it can send all session details also)
I have tried below with no success
public void httprequests()
{
string _url = repo.WebDocumentEzprints_ecommerce.Self.PageUrl.ToLower();
Uri _uri = new Uri(_url);
HttpWebRequest lWebRequest = (HttpWebRequest) WebRequest.Create(_uri);
HttpWebResponse lWebResponse = (HttpWebResponse)
lWebRequest.GetResponse();
//StreamReader lResponseStream = new StreamReader();
Encoding encode = Encoding.GetEncoding("utf-8");
//StreamReader(lWebResponse.GetResponseStream(),encode);
Stream receiveStream = lWebResponse.GetResponseStream();
//StreamReader reasstream = new StreamReader(receiveStream,encode);
StreamReader readStream = new StreamReader( receiveStream, encode );
Console.WriteLine("\r\nResponse stream received.");
Char[] read = new Char[256];
// Reads 256 characters at a time.
int count = readStream.Read( read, 0, 256 );
Console.WriteLine("HTML...\r\n");
while (count > 0)
{
// Dumps the 256 characters on a string and displays the string to the console.
String str = new String(read, 0, count);
Console.Write(str);
count = readStream.Read(read, 0, 256);
}
Console.WriteLine("");
lWebRequest = null;
lWebResponse.Close();
//lResponseStream.Close();
}
it is giving me th xml in viewsource.
Any information on this will be very helpful
Thanks,
Abhigna