There's a couple of ways that you could do this. The easiest would be to create a variable that the value goes into when you first get it.
Because there's bound to be (and have been) cases where they need to be separated out a bit more, I typically write the value into an xml file that is used as a data source in the tests that will use this value.
There's the possibility of taking a little bit of a hit on the performance of your tests, but, from my experience, it's ended up being negligible.
Resolution ##
edited by @anicho
1) Create a querystring parameter under the request for the relevant querystring, in our case its "suid". Give it a context parameter value ours would be {{suid}}.
2) Next you need to create a custom extraction class, you can follow enter link description here to create an extraction class.
3) To caputre the query string use the code I have written below.
using System;
using System.Linq;
using Microsoft.VisualStudio.TestTools.WebTesting;
using System.Globalization;
namespace CustomExtractionRule
{
//-------------------------------------------------------------------------
// This class creates a custom extraction rule named "Custom Extract Input"
// The user of the rule specifies the name of an input field, and the
// rule attempts to extract the value of that input field.
//-------------------------------------------------------------------------
public class SuidExtraction : ExtractionRule
{
/// Specify a name for use in the user interface.
/// The user sees this name in the Add Extraction dialog box.
//---------------------------------------------------------------------
public string DisplayNameAttribute
{
get { return "SuidExtraction"; }
}
/// Specify a description for use in the user interface.
/// The user sees this description in the Add Extraction dialog box.
//---------------------------------------------------------------------
public string DescriptionAttribute
{
get { return "Extracts the suid from query strings"; }
}
// The queryname of the desired query string you wish to capture, when you add the custom extraction to a request you can set the following value to be what ever you like, it's like this so it can be reused over and over again.
private string _queryNameValue;
public string QueryName
{
get { return _queryNameValue; }
set { _queryNameValue = value; }
}
// The Extract method. The parameter e contains the web performance test context.
//---------------------------------------------------------------------
public override void Extract(object sender, ExtractionEventArgs e)
{
if (e.Response.HtmlDocument != null)
{
foreach (QueryStringParameter item in e.Request.QueryStringParameters)
{
if (item.Name.Equals("suid"))
{
// add the extracted value to the web performance test context
e.WebTest.Context.Add(this.ContextParameterName, item.Value);
e.Success = true;
return;
}
}
}
// If the extraction fails, set the error text that the user sees
e.Success = false;
e.Message = String.Format(CultureInfo.CurrentCulture, "Not Found: {0}", QueryName);
}
}
}
4) Once the code executes it picks up the query strings value and assigns it to a context parameter. The context parameter we ask our query string value to grab should be the same. As soon as the code sets it our query string picks it up and hey presto it should all be gravy.
Extra hint I need to use the same query string value in future requests within the same test so I set up a permenant context parameter so it can get picked up out side the one request.