简体   繁体   中英

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM