locked
Change Request BodyString - How ?

    Question

  • I run Load test with 3 scenarios inside.

    I need to manage one scenario manually by webtest plugin 

    In scenario, every new running i need to change user&password in login request - but the string is inside the request BODY:

     

    my Request BodyString look like:

        @Loginhttp://tempuri.org/@userName�administrator@AD1.local@password� 1qaz@@wsx@ isPersistent�@

        customData.nil� i)http://www.w3.org/2001/XMLSchema-instance

     

      1. How I can change the request Body ? (I try with e.Request.Body but i can't get value to StringBody )

      2. I need to change the user&password value from pool of 20 users - what is the best way ?

         ( test1 will take first user&password, test20 will take 20th user&password, test21 will take again the first user&password. )

          it possible to create static value in webtest that hold counter of "number of running test" or should i create a LoadTest plugin

          And find when my problematic web test is running ? 

     


    MIRO77
    • Edited by Miro1977 Sunday, January 16, 2011 12:17 PM edit
    Saturday, January 15, 2011 3:51 PM

Answers

  • Hello Micro1977,

     

    Welcome to MSDN Forum again, Thank you  for your engaging our forum.

    My name is Shane Hu and I will be working with you on this case.

    We will be working together to solve this issue, so please feel free to let me know if I have misunderstood anything.

     

    According to you description of the problem, the issue you are experiencing is :

    1.  You have twenty users to make a load test.

    2.  In this load test, you want the load test to be made shoud be scoll by obeying the sequence of users.  

     

    If I had misunderstood anything, please feel free to tell me.

    I have some ideas to advise  you to solve this issue, which are as follows:

    1.       The web test provide methods to you to bind web fields value to  the datarow in database.

    2.       The process of the load test was made scrolly by obeying the sequence of users, so you should develop a plug-in to make each user execute each username/password, which was used in load test, I thought it could be help you,such as code below:

           using Microsoft.VisualStudio.TestTools.WebTesting;
           namespace Example
           {
                  public class DatasourcePlugin : WebTestPlugin
                  {
                       static int counter = 0;       

                       public override void PreWebTest(object sender,PreWebTestEventArgs e)
                       {
                             while ((counter++ % e.WebTest.Context.AgentCount) != (e.WebTest.Context.AgentId - 1))
                             {
                                  e.WebTest.MoveDataTableCursor("DatasourceName", "TableName");
                             }
                       }
                  }
           }

    I hope these ideas will help you to solve your issue.

    Best Regards,

    Shane Hu

     


     

    Hualiang Hu [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

     

    Tuesday, January 18, 2011 3:20 AM
    Moderator
  • Hi Miro77,

    Is this issue fixed? If not,please let me know.

    Best Regards,

    Shane


    Hualiang Hu [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Friday, January 28, 2011 5:45 AM
    Moderator
  • I was found a great plugin to use with Binary files format.

    http://blogs.msdn.com/b/mahipalkante/archive/2010/04/07/web-test-plugins-for-web-service-messages.aspx

     

    With plugin i success to change the binary requests and associate it to data source.

    Tnx. 


    MIRO77
    Sunday, February 06, 2011 12:48 PM

All replies

  • I already solved my first question :

     

    string Tmpstring = string.Empty;
    StringHttpBody st;
    
    st = (StringHttpBody)e.Request.Body;
    Tmpstring = st.BodyString;
    

     

     But I still need idea to the second question..

     

    Tnx.


    MIRO77
    • Edited by Miro1977 Sunday, January 16, 2011 12:42 PM edit
    • Proposed as answer by Shai RaitenMVP Monday, January 17, 2011 6:38 AM
    Sunday, January 16, 2011 12:41 PM
  • Hello Micro1977,

     

    Welcome to MSDN Forum again, Thank you  for your engaging our forum.

    My name is Shane Hu and I will be working with you on this case.

    We will be working together to solve this issue, so please feel free to let me know if I have misunderstood anything.

     

    According to you description of the problem, the issue you are experiencing is :

    1.  You have twenty users to make a load test.

    2.  In this load test, you want the load test to be made shoud be scoll by obeying the sequence of users.  

     

    If I had misunderstood anything, please feel free to tell me.

    I have some ideas to advise  you to solve this issue, which are as follows:

    1.       The web test provide methods to you to bind web fields value to  the datarow in database.

    2.       The process of the load test was made scrolly by obeying the sequence of users, so you should develop a plug-in to make each user execute each username/password, which was used in load test, I thought it could be help you,such as code below:

           using Microsoft.VisualStudio.TestTools.WebTesting;
           namespace Example
           {
                  public class DatasourcePlugin : WebTestPlugin
                  {
                       static int counter = 0;       

                       public override void PreWebTest(object sender,PreWebTestEventArgs e)
                       {
                             while ((counter++ % e.WebTest.Context.AgentCount) != (e.WebTest.Context.AgentId - 1))
                             {
                                  e.WebTest.MoveDataTableCursor("DatasourceName", "TableName");
                             }
                       }
                  }
           }

    I hope these ideas will help you to solve your issue.

    Best Regards,

    Shane Hu

     


     

    Hualiang Hu [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

     

    Tuesday, January 18, 2011 3:20 AM
    Moderator
  • Tnx Shane_Hu

    I will try it and post here if it was good.

    Tnx.


    MIRO77
    Tuesday, January 18, 2011 8:41 AM
  • Hi Miro77,

    Is this issue fixed? If not,please let me know.

    Best Regards,

    Shane


    Hualiang Hu [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Friday, January 28, 2011 5:45 AM
    Moderator
  • I was found a great plugin to use with Binary files format.

    http://blogs.msdn.com/b/mahipalkante/archive/2010/04/07/web-test-plugins-for-web-service-messages.aspx

     

    With plugin i success to change the binary requests and associate it to data source.

    Tnx. 


    MIRO77
    Sunday, February 06, 2011 12:48 PM