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

Null Reference Exception when trying to use the HTTP proxy

2 Answers 88 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Daniel
Top achievements
Rank 1
Daniel asked on 24 Apr 2012, 12:53 AM
I am trying to use the HTTP proxy with the code in the block below.  The Set web proxy set is run as step 1 of the test to initialize the settings and relaunch the browser.  When I get to the AddBeforeResponseListener I am getting a null reference exception( Object reference not set to an instance of an object..)  I am clearly missing an initialization step somewhere but I am not sure where.  

I am use the TS plugin version 2012.1.420.0 with VS2010 on a win7 64 bit box.

[CodedStep(@"Set WebProxy")]
        public void TradeList_CodedStep4()
        {
            ActiveBrowser.Close();
            Manager.Settings.Web.UseHttpProxy = true;
            Manager.LaunchNewBrowser();
        }
 
        [CodedStep(@"Click 'ContentPlaceHolderRwDldFilesCLbGenerateBulkReportLink'")]
        public void TradeList_CodedStep3()
        {
            ResponseListenerInfo li = new ResponseListenerInfo(GetFileFromHeaderInfo);
            Manager.Http.AddBeforeResponseListener(li);
 
            // Click 'ContentPlaceHolderRwDldFilesCLbGenerateBulkReportLink'
            Pages.TamaracIncCom7.ContentPlaceHolderRwDldFilesCLbGenerateBulkReportLink.Click(false);
 
            Manager.Http.RemoveBeforeResponseListener(li);
 
            //string getPostBack = (string)GetExtractedValue("BulkReportJavaScript");
            //string parsedPostBack = getPostBack.Substring(11);
 
            //var response = Actions.InvokeScript(parsedPostBack);
                       
        }
 
        private void GetFileFromHeaderInfo(object sender, HttpResponseEventArgs e)
        {
            System.Collections.Specialized.NameValueCollection headers = e.Response.Headers;
             
        }

2 Answers, 1 is accepted

Sort by
0
Accepted
Anthony
Telerik team
answered on 26 Apr 2012, 10:20 PM
Hello Daniel,

The issue is that your setting to turn on the HttpProxy is not being respected, and there's nowhere to turn it on through the UI for Quick Execution. (It exists for Test Lists, however). There's an existing feature request for this and you can vote for it here

In the meantime, here's a work-around:

1. Disable the first coded step in the TradeList test.
2. Create a new parent test and add a coded step that does the following:

[CodedStep(@"New Coded Step")]
public void ProxyParent_CodedStep()
{
    Settings settings = new Settings();
    settings.Web.UseHttpProxy = true;
 
    ResultSummary results = RunHelper.Test(@"C:\Users\rinaldi\Documents\Visual Studio 2010\Projects\TestProject3\TestProject3\Tests\ProxyStuff.tstest", settings, @"C:\Users\rinaldi\Documents\Visual Studio 2010\Projects\TestProject3\TestProject3\bin\Debug\TestProject3.dll");
}


Kind regards,
Anthony
the Telerik team
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
0
Daniel
Top achievements
Rank 1
answered on 27 Apr 2012, 12:17 AM
I can get this to work through in visual studio by adding a test settings file to the project and enabling it there.  It still does not work with test execute but I can at least debug it and get the information I need to build the test.  The link about the test lists shows that as well.
Tags
General Discussions
Asked by
Daniel
Top achievements
Rank 1
Answers by
Anthony
Telerik team
Daniel
Top achievements
Rank 1
Share this question
or