locked
How to customize a web performance test for saving the data returned from a webservice to excel/xml? RRS feed

  • Question

  • Hi

    I have a recorded a web performance test on the application.And it has the following steps which i want to customize.

    1.Open the web application.

    2.Enter the Agent ID value in AgentID textbox .(I want to parameterize the AgentID value for each load so that i can specify different value everytime)

    3.Click on search button and the web service returns the sales made by that particular AgentID so far.(I want to save the returned xml data to local disk each time with a different file name for each user/load )

     

    Can anyone help me with pointers on how to implement this .Any help would be greatly appreciated.

    Thanks.

     


    Regards Krrishna
    Wednesday, February 1, 2012 3:54 AM

Answers

  • Krrishna,

    You can do so with help of custom extraction rules. You can author an extraction rule that will write the response of the Search button click request to file and store it in local disk.

    1. When you run the web test, check the Body section in response tab of Web Performance Test Results Viewer. It will show you the response of the server(shall be xml in your case of a web service call). You can access the sme in Extraction rule using:
      string bodyString = e.Response.BodyString;
      
    2. For details on Extraction Rules, refer: http://msdn.microsoft.com/en-us/library/ms243179(v=vs.100).aspx.
    3. Write the code to create file with unique names that contain the response.
    4. To parameterize the AgentID textbox input value, there will be a form post parameter in that request whose value shall be the hardcoded input value. You can create a datasource and bind it to that parameter. See http://msdn.microsoft.com/en-us/library/ms404707.aspx

    -Tejas.

    • Proposed as answer by TejasJ Wednesday, February 1, 2012 6:41 AM
    • Marked as answer by Krrisshna Wednesday, February 1, 2012 8:07 AM
    Wednesday, February 1, 2012 4:19 AM
  • Well, you need to change the Xml slightly. In current schema, you have multiple columns(Alias 1,2,3..) of a single row of Names table. Change it to something similar to:

    <?xml version="1.0" encoding="utf-8"?>
    <AgentsList>
      <Agent Row="0" Alias="johns" />
      <Agent Row="1" Alias="sraj" />
      <Agent Row="2" Alias="kris" />
      <Agent Row="3" Alias="anlik" />
    </AgentsList>
    

    Let us assume that the datasourcename is Datasource1 then, you can access alias using:

    {{DataSource1.Agent.Alias}}
    

    See How to: Configure Web Performance Tests to Run Once Per Data Row Using Test Settings.

    -Tejas.

    • Marked as answer by Krrisshna Wednesday, February 1, 2012 8:07 AM
    • Edited by TejasJ Wednesday, February 1, 2012 8:30 AM
    Wednesday, February 1, 2012 8:04 AM

All replies

  • Krrishna,

    You can do so with help of custom extraction rules. You can author an extraction rule that will write the response of the Search button click request to file and store it in local disk.

    1. When you run the web test, check the Body section in response tab of Web Performance Test Results Viewer. It will show you the response of the server(shall be xml in your case of a web service call). You can access the sme in Extraction rule using:
      string bodyString = e.Response.BodyString;
      
    2. For details on Extraction Rules, refer: http://msdn.microsoft.com/en-us/library/ms243179(v=vs.100).aspx.
    3. Write the code to create file with unique names that contain the response.
    4. To parameterize the AgentID textbox input value, there will be a form post parameter in that request whose value shall be the hardcoded input value. You can create a datasource and bind it to that parameter. See http://msdn.microsoft.com/en-us/library/ms404707.aspx

    -Tejas.

    • Proposed as answer by TejasJ Wednesday, February 1, 2012 6:41 AM
    • Marked as answer by Krrisshna Wednesday, February 1, 2012 8:07 AM
    Wednesday, February 1, 2012 4:19 AM
  • I will try capturing the response xml in bodyString and then to a different file each time.

    About your answer to other question i want to share some info where the string body i want to parameterize has some text like below.And i want to just parametreize johns(that is agentid tag below) from this string body.For simple parameters i could parameterize usign the datasource.But this one is in the form of XML.

    <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"><s:Body><AgentSalesReport xmlns="http://tempuri.org/"><agentid>Johns</agentid><fromDate i:nil="true" xmlns:i="http://www.w3.org/2001/XMLSchema-instance" /><toDate i:nil="true" xmlns:i="http://www.w3.org/2001/XMLSchema-instance" /></AgentSalesReport></s:Body></s:Envelope>


    Regards Krrishna
    Wednesday, February 1, 2012 5:45 AM
  • You should be able to do so by concatinating string and the parameter/datasource such as:

    <agentid>{{AgentIDContextParameters}}</agentid>
    
    <agentid>{{Agents.Agents#csv.AgenttID}}</agentid>
    

    -Tejas.

    • Proposed as answer by TejasJ Wednesday, February 1, 2012 8:30 AM
    Wednesday, February 1, 2012 6:05 AM
  • I have added the following xml datasource but htrows error "Request failed: Context parameter 'Names.Alias2' not found in test context"

    <?xml version="1.0" encoding="utf-8"?>
    <Names>
      <Alias1>johns</Alias1>
      <Alias2>sraj</Alias2>
      <Alias3>kris</Alias3>
      <Alias4>anlik</Alias4>
    </Names>


    Regards Krrishna
    Wednesday, February 1, 2012 7:11 AM
  • Because you are using datasource, use second option:

    <agentid>{{Agents.Agents#csv.AgenttID}}</agentid>
    

    The format will be: [Datasource].[Table].[Column]

    By the way, its giving error for Alias2. So did it work for first iteration?

    Wednesday, February 1, 2012 7:17 AM
  • As a first step i have hardcoded the DataSource1.Names.Alias1 in that xml tag and it worked .

    Now one more query here is how can i make  it move to the next tag which is alias2 with value sraj?


    Regards Krrishna
    Wednesday, February 1, 2012 7:34 AM
  • Well, you need to change the Xml slightly. In current schema, you have multiple columns(Alias 1,2,3..) of a single row of Names table. Change it to something similar to:

    <?xml version="1.0" encoding="utf-8"?>
    <AgentsList>
      <Agent Row="0" Alias="johns" />
      <Agent Row="1" Alias="sraj" />
      <Agent Row="2" Alias="kris" />
      <Agent Row="3" Alias="anlik" />
    </AgentsList>
    

    Let us assume that the datasourcename is Datasource1 then, you can access alias using:

    {{DataSource1.Agent.Alias}}
    

    See How to: Configure Web Performance Tests to Run Once Per Data Row Using Test Settings.

    -Tejas.

    • Marked as answer by Krrisshna Wednesday, February 1, 2012 8:07 AM
    • Edited by TejasJ Wednesday, February 1, 2012 8:30 AM
    Wednesday, February 1, 2012 8:04 AM
  • Thanks Teja.Looks like it goes to the next row in xml automatically and picks the next alias.
    Regards Krrishna
    Thursday, February 2, 2012 8:28 AM