user185320
user185320

Reputation: 103

Visual Studio Web Performance Test

I'm running into a "bad request" error when playing back a test. I've tracked it down to a comma and space in a button that has "Yes, Do" as its value. There is functionality in another page that runs based on this value. When I remove the comma and space in the both pages everything works perfectly. I've tried toggling the 'url encode' property for that field in the Web Perf Test to true, but it still fails. When I look at the details of the request it shows "Yes,+Do" as the querystring param. I can't change the control value in this situation. Any hints?

Upvotes: 1

Views: 1305

Answers (1)

Sam Woods
Sam Woods

Reputation: 1850

It seems odd that the value of a button is being passed as a query string parameter in the first place...

Is it set up where there is an extraction rule from a prior request and then that context parameter is used for a later request? If so, you can actually modify the value. You can either hard code the value in the later request, or if you still need to get it dynamically but just modify it, you can create a pretty simple plugin. Sample code for it would be:

public class StringCharsFromParam: WebTestRequestPlugin
{
    public override void PreRequest(object sender, PreRequestEventArgs e)
    {
        string ExtractParam =  ((string)e.WebTest.Context["NameOfContextParameter"]);
        if (ExtractParam != null && ExtractParam.Contains(", ")
        {
            e.WebTest.Context["NameOfContextParameter"] = ExtractParam.Replace(", ", "");
        }
    }
}

You would then add this WebTestRequestPlugin to your WebTest.

Upvotes: 1

Related Questions