capture http traffic with databound test

2 posts, 0 answers
  1. Pete
    Pete avatar
    4 posts
    Member since:
    Sep 2012

    Posted 16 May 2013 Link to this post

    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));
                    }
                }
            }
  2. Plamen
    Admin
    Plamen avatar
    8 posts

    Posted 18 May 2013 Link to this post

    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
Back to Top