Dynamically Add Dependent Request RRS feed

  • Question

  • Is it possible to dynamically add a dependent request to a web request by using a WebTestRequestPlugin (or other plugin mechanism)?

    Is it possible to dynamically create a new web request by using a WebTestRequestPlugin (or other plugin mechanism)?

    The relevant test scenario is:

     - A pre-recorded 'Search' request is done with a random search string

     - The request response body is parsed and data is extracted to be used in dynamically generated dependent requests or possibly new requests



    Wednesday, December 14, 2011 10:34 AM

All replies

  • Hi,

    It should be possible. You should be able to send a request and parse the response using HTTPWebRequest/HTTPWebRepsonse



    Thursday, December 15, 2011 3:29 AM
  • Hi Piotr,


    I am writing to check the status of the issue on your side.

    What about this problem now?

    Would you mind letting us know the result of Anuj’s suggestion?


    Best Regards,

    Jack Zhai [MSFT]
    MSDN Community Support | Feedback to us
    Friday, December 23, 2011 6:31 AM
  • Hi!

    I'm also having this problem. The thing is that I have to send the request to get a response body that I can parse. By then it is already too late to add the dependent requests. It is a "Catch 22". But maybe there is a way to get around this problem?

    Friday, December 23, 2011 3:16 PM
  • I have a working solution, can you verify if it fits you needs?

    1. Record web test;
    2. Generate Coded web test based on recorded web test;
    3. Add dependent web request in PreRequest event

    Let me know if there's anything unclear, I'll try to help.


    public override IEnumerator<WebTestRequest> GetRequestEnumerator()
        // Initialize validation rules that apply to all requests in the WebTest
        WebTestRequest request1 = new WebTestRequest((this.Context["WebServer2"].ToString() + "/"));
        request1.ThinkTime = 3;
        ExtractHiddenFields extractionRule1 = new ExtractHiddenFields();
        extractionRule1.Required = true;
        extractionRule1.HtmlDecode = true;
        extractionRule1.ContextParameterName = "1";
        request1.ExtractValues += new EventHandler<ExtractionEventArgs>(extractionRule1.Extract);
        request1.PreRequest += new EventHandler<PreRequestEventArgs>(wtr_PreRequest);
        yield return request1;
        request1 = null;
    void wtr_PreRequest(object sender, PreRequestEventArgs e)
        WebTestRequest dependency = new WebTestRequest("http://localhost:17650/blue.aspx");


    Forrest Guo | MSDN Community Support | Feedback to us

    Monday, December 26, 2011 10:55 AM
  • As I pointed out in the original question I needed the response information from the first request in order to build the follow up web requests.

    In our solution we do the following:

    - send 'Search' request that has a PostRequest event handler

    - In the PostRequest event handler the 'Search' response is parsed and the extracted data is saved in a context parameter

    - Then the data in the context parameter is used to build the dynamic follow up web requests

    The follow up requests are of course NOT dependent web requests for the original 'Search'. But that is just the result of the requirement that dynamic requests are generated depending on the 'Search' reply.



    Tuesday, December 27, 2011 10:29 AM
  • Piotr,

    Have you worked out the requirement? Do you still need assistance?

    Best Regards,

    Forrest Guo | MSDN Community Support | Feedback to us

    Thursday, December 29, 2011 3:43 PM