Team System Developer Center >
Visual Studio Team System Forums
>
Visual Studio Web Performance and Load Testing
>
How to use same jsessionid value throughout the webtest
How to use same jsessionid value throughout the webtest
- Hi,I am using VSTT 2008. I need to use the same jsession id value through out the test. Here is what my test doesWhen it opens the main page, a cookie is set in the request header as Cookie=JSESSIONID=<value>. Now i need to carry over this value to all the subsequent requests. I cannot hardcode that since the ID is valid for some time and it expired soon.What my test is doing is that it created a new session id for each step, hence the test fails after 3 steps. I need to carry the Session id generated in the first requests to all the subsequent requests.Thanks in advance for help.
Answers
- Hello Kuldeep,
As I do not know how your web site works, if you want to extract value from request, you may utilize web test request plug in to extract this value and have it binded to context parameter which you could use in the whole web test.
The below codes work fine on my machine and you may refer to:
public class Class1:WebTestRequestPlugin
{
public override void PostRequest(object sender, PostRequestEventArgs e)
{
string extractValue = "";
foreach(WebTestRequestHeader t in e.Request.Headers)
{
if (t.Name == "Host") //find the specific header value and bind it to context parameter
e.WebTest.Context["Jsession"] = t.Value;
}
}
}
More detailed information about request plug in, you can refer to the following article:
http://msdn.microsoft.com/en-us/library/bb514192.aspx
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Send us any feedback you have about the help from MSFT at fbmsdn@microsoft.com.- Marked As Answer byEdwer FangMSFT, ModeratorFriday, November 13, 2009 2:30 AM
All Replies
- you just need to add Extraction rule -"Extract Text" and extract the value that you need and set Content Parameter Name = J_id (or any other name ).
In the other request attach the Context Parameter (J_id) to somewhere you need it.
MIRO77 - Hello,
Based on your description, you want to carry the Session id generated in the first requests to all the subsequent requests. You may follow Miro1977's suggestion to do it. As extraction rule could extract specific value from the response and bind it to a context parameter which could be used in all test. You just need to verify the response of the first request and create proper extraction rule.
More detailed information about Extraction Rule, you may follow the following article:
http://msdn.microsoft.com/en-us/library/ms404703.aspx
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Send us any feedback you have about the help from MSFT at fbmsdn@microsoft.com. - The cookie value from the first request should be carried forward to following requests. Does each of the following responses also get a SET-Cookie header for jsessionid?
- Hi,Thanks for the reply. I don't have the Session id value in my response. Its only in the request. So i cant play with response too. One more thing i wanted to know is that can we set the asynchronous property of cookies in the test or is it read only.
- Hello Kuldeep,
As I do not know how your web site works, if you want to extract value from request, you may utilize web test request plug in to extract this value and have it binded to context parameter which you could use in the whole web test.
The below codes work fine on my machine and you may refer to:
public class Class1:WebTestRequestPlugin
{
public override void PostRequest(object sender, PostRequestEventArgs e)
{
string extractValue = "";
foreach(WebTestRequestHeader t in e.Request.Headers)
{
if (t.Name == "Host") //find the specific header value and bind it to context parameter
e.WebTest.Context["Jsession"] = t.Value;
}
}
}
More detailed information about request plug in, you can refer to the following article:
http://msdn.microsoft.com/en-us/library/bb514192.aspx
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Send us any feedback you have about the help from MSFT at fbmsdn@microsoft.com.- Marked As Answer byEdwer FangMSFT, ModeratorFriday, November 13, 2009 2:30 AM


