Web Performance Testing context paramters

I used the MSDN guide on creating Custom Extraction Rule, which presents this example (Extract method):

    public override void Extract(object sender, ExtractionEventArgs e)
        if (e.Response.HtmlDocument != null)
            foreach (HtmlTag tag in e.Response.HtmlDocument.GetFilteredHtmlTags(new string[] { "input" }))
                if (String.Equals(tag.GetAttributeValueAsString("name"), Name, StringComparison.InvariantCultureIgnoreCase))
                    string formFieldValue = tag.GetAttributeValueAsString("value");
                    if (formFieldValue == null)
                        formFieldValue = String.Empty;

                    // add the extracted value to the web performance test context
                    e.WebTest.Context.Add("someNameHere", formFieldValue);
                    e.Success = true;
        // If the extraction fails, set the error text that the user sees
        e.Success = false;
        e.Message = String.Format(CultureInfo.CurrentCulture, "Not Found: {0}", Name);

However, I just don’t know how to use access the someNameHere in the Web Test and add it to the QueryString as a parameter.

Any help would be greatly appreciated.

Here is Solutions:

We have many solutions to this problem, But we recommend you to use the first solution because it is tested & true solution that will 100% work for you.

Solution 1

Right-click on the request in the web test and select “Add URL query string parameter”. Alter the name as needed and into the value field enter {{someNameHere}}. The doubled curly braces call for a context parameter value to be inserted. The doubled curly braces can be used to insert the value of a context parameter into many other places in a web test. Note that strings such as text{{someNameHere}}moretext can be used to join context values to other strings.

Note: Use and implement solution 1 because this method fully tested our system.
Thank you 🙂

All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply