This is a migrated thread and some comments may be shown as answers.

capture http traffic with databound test

1 Answer 30 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Pete
Top achievements
Rank 1
Pete asked on 16 May 2013, 07:11 PM
the responsehandler is called with the first row in the spreadsheet but with subsequent rows the responsehandler is not called.

 Settings testSettings = new Settings();  
            testSettings.Web.UseHttpProxy = true;       
            Manager mgr = new Manager(testSettings);
            try
            {             
                mgr.Start();               
                ResponseListenerInfo li = new ResponseListenerInfo(ResponseHandler);
                Debug.WriteLine("instantiated listener");
                mgr.Http.AddBeforeResponseListener(li);
                Debug.WriteLine("added listener");
                mgr.LaunchNewBrowser(BrowserType.InternetExplorer, true);
                url = string.Format("http://{0}{1}", domain, Data["url"]);
                mgr.ActiveBrowser.NavigateTo(url);
                
                mgr.ActiveBrowser.WaitUntilReady();
                mgr.Http.RemoveBeforeResponseListener(li);
                // System.Threading.Thread.Sleep(3000);
                mgr.ActiveBrowser.Close();
                // li=null;               
            }
            catch(Exception e){
                Debug.WriteLine(string.Format("error {0}",e.Message));   
            }
            finally
            {                   
               mgr=null;
               Debug.WriteLine("finally");
                System.Threading.Thread.Sleep(5000);
            }
        }
        
        private void ResponseHandler(object sender, HttpResponseEventArgs e)
        {            
            Debug.WriteLine(string.Format("{0} - {1}", e.Response.Request.RequestUri,e.Response.StatusCode));
            int[] codes=new int[]{301,302,303,304,305,306,307};
            if (codes.Contains<int>(e.Response.StatusCode)){
               
               Assert.IsTrue(false);
                
            }
            System.Collections.Specialized.NameValueCollection headers = e.Response.Headers;
            if (url == e.Response.Request.RequestUri )
            {
            
                //some are reported as soft but they are real pages.
                if (e.Response.StatusCode != 200)
                {                 
                    Assert.IsTrue(ArtOfTest.Common.CompareUtils.StringCompare(e.Response.StatusCode.ToString(), "404",
                                                                              FindCompareType.Exact));
                }
            }
        }

1 Answer, 1 is accepted

Sort by
0
Plamen
Telerik team
answered on 18 May 2013, 12:04 PM
Hello Pete,

I am sorry to hear you are running into this problem. Unfortunately I'm not able to reproduce it locally. Could you please send us a sample test project against public web site? This will help us to reproduce the issue in our source code debugging environment and find the root cause of it.

All the best,
Plamen
the Telerik team
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
Tags
General Discussions
Asked by
Pete
Top achievements
Rank 1
Answers by
Plamen
Telerik team
Share this question
or