locked
VSTS 2010 404 error display RRS feed

  • Question

  • Hi all,

    I have recorded web test, after replaying the web test, all the request gets passed with 200 status code and data also got successfully updated in the application, but the some of the request symbol shows red indication with 404 status code inside the request(http://localhost/proof/ig_res/Default/ig_shared.css)..

    Please help me to remove the 404 & 403(css file) from web test..

    Tuesday, February 19, 2013 5:55 AM

Answers

  • What exactly do you want?

    - do you want to remove all css files?

    - does these requests are recorded or generated from the main page as dependent request?

    if it is recorded dependent request - you can delete them, or set their "expected http code".

    if it is auto generated requests - you can identifies those requests on a WebTestPlugin.PreRequest and then sets there "excpected" status code, or even "skip" this request.

    Tuesday, February 19, 2013 2:35 PM

All replies

  • What exactly do you want?

    - do you want to remove all css files?

    - does these requests are recorded or generated from the main page as dependent request?

    if it is recorded dependent request - you can delete them, or set their "expected http code".

    if it is auto generated requests - you can identifies those requests on a WebTestPlugin.PreRequest and then sets there "excpected" status code, or even "skip" this request.

    Tuesday, February 19, 2013 2:35 PM
  • I have the following webtestplugin to make a dependant 404 as a pass. It works fine in a webtest, but I still see them showing up as 404 errors in a loadtest (I am using vs2013 ultimate). Is there a way to stop it from showing the errors in a loadtest or the only way is to remove the dependant request i.e. not make that request (which is deviating from what really happens).

    using System.Collections.Generic;
    using Microsoft.VisualStudio.TestTools.WebTesting;
    public class WebTestDependentFilter : WebTestPlugin
    {
        public override void PostRequest(object sender, PostRequestEventArgs e)
        {
            base.PostRequest(sender, e);
            foreach (WebTestRequest r in e.Request.DependentRequests)
            {
                r.PostRequest += new System.EventHandler<PostRequestEventArgs>(r_PostRequest);
            }
        }

        void r_PostRequest(object sender, PostRequestEventArgs e)
        {
            if (e.Response.StatusCode == System.Net.HttpStatusCode.NotFound)
            {
                e.Request.Outcome = Outcome.Pass;
                System.Diagnostics.Debug.WriteLine("Dependent request not found: " + e.Request.Url);
            }
        }
    }

    Tuesday, September 16, 2014 6:28 PM
  • Another approach to handling 404s is to remove the requests before they are issued. Run the test and identify the URLs that yield 404s. The code shown on page 189 pf the Visual Studio Performance Testing (not so) Quick Reference Guide shows how to remove unwanted dependant requests. See http://vsptqrg.codeplex.com/

    Regards

    Adrian

    Tuesday, September 16, 2014 9:29 PM
  • btw the code in the Guide is not entirely complete .. it won't compile. Anyway if I know the requests that will cause 404 the better and ideal solution is to set that up so that the expected status code is 404. I worked on this today and the code looks like below (and it works .. all tested).

    HOWEVER I was looking for a better solution in which any dependant request that yields a 404 does not generate an error so that we don't need to know up front which requests to handle differently. Isn't there a way to do this: "if request has 404, do not generate error and pass this request"

                

    using Microsoft.VisualStudio.TestTools.WebTesting;
    
    public class WebTestDependentFilter : WebTestPlugin
    {
        public string urlFilter;
        
        public override void PostRequest(object sender, PostRequestEventArgs e)
        {
            base.PostRequest(sender, e);
            
            foreach (WebTestRequest r in e.Request.DependentRequests)
            {
                if (!string.IsNullOrEmpty(urlFilter) && r.Url.Contains(urlFilter)) r.ExpectedHttpStatusCode = 404;    
            }
        }
    }


    Tuesday, September 16, 2014 10:12 PM