Showing posts with label Load test. Show all posts
Showing posts with label Load test. Show all posts

Monday, January 16, 2012

Visual Studio Web Test: Excluding resources that are failing the test

I had a recorded scenario that when running back, one resource was giving 404 error, and because of that the test was failing

this resource was not important, it was just a css file, I looked on how to exclude such non-important resources from the test, I found some useful information here http://blogs.msdn.com/b/densto/archive/2007/06/27/webtestrequest-dependentrequests-collection.aspx

so first I converted my test to web coded test, then I looked for the request that was causing the problem, then I added this line before the yeld command for the request

request4.PostRequest += new EventHandler<PostRequestEventArgs>(request4_PostRequest);

Then added the request4_PostRequest implementation at the end

void request4_PostRequest(object sender, PostRequestEventArgs e)
{
    List<WebTestRequest> remove = new List<WebTestRequest>();
    foreach (WebTestRequest dependent in e.Request.DependentRequests)
    {
        if (dependent.Url.EndsWith("template.css"))
        {
            remove.Add(dependent);
        }
    }

    foreach (WebTestRequest dependent in remove)
    {
        e.Request.DependentRequests.Remove(dependent);
    }
}

Doing the above, I am able to run the test and getting pass as a final result

Another easier way I found later from Ed Glas post http://blogs.msdn.com/b/edglas/archive/2008/08/06/masking-a-404-error-in-a-dependent-request.aspx

This way can be done on the recorded scenario directly without converting to coded test

Sunday, January 15, 2012

Visual Studio Web test, creating extraction rule

I was creating a web test for a flow, with several forms, I had an ID that I wanted to use later in other requests, that wasn’t detected by the Visual studio parameter automatic linking.

The easiest way to do that

1- I did a run for the recorded scenario

2- I searched for the request that was displaying the ID on the screen

3- I went to the Response tab, where I can see the response html

image

4- I looked for the ID that I need to extract

5- Select the text that you want to extract, then do a right click and select Add Extraction Rule

image

After doing so, the web test will be opened and a confirmation will be displayed showing the rule name

image

image

 

If the required text is at the beginning of the line, you might need to add “\n” at the end of the “Starts with”