Answered by:
[Extract HTTP Header & Extract Regular expression]

Question
-
Hello Group ,,
I'm testing every rule in built in extraction Rule ,, i want to know more about Extract Http header and Extract Regular expression ,,
where to find them in HTML page ???
can any body help me ??
thanks in advance
Thursday, June 5, 2008 7:34 PM
Answers
-
Refer back to wavyknight12's example. You would specifiy "Content-Length" for the "HTTP Name" field name. You would specify any value you like for the "Context Parameter" field (let's say you chose "length" as the name of the variable you want set). After the extraction rule completes, you would have a context parameter with name "length" and value "157".
Refer back to the link in wavyknight12's reply. The link include should tell you everything you need to know about Regular Expressions. But to answer you question, yes you would put "(0|1|2|3|4|5|6|7|8|9)" in the regular expression field (or any valid regular expression -- again, see the link for more details on regular expressions)
Thanks,
Rick
Friday, June 6, 2008 1:15 PMModerator
All replies
-
vagueraz
Extract Http header is used to extract an HTTP header value from the response and place the value of the header into the WebTestContext.
Consider the following HTTP headers:
MicrosoftSharePointTeamServices : 12.0.0.4518
Content-Length : 157
Cache-Control : privateYou can create an Extract Http header to extract the "Content-Length", "Cache-Control" value and access them by the Context property of WebTest class.
Extract Regular Expression rule extracts text from the response that matches the regular expression pattern. For example, you can use "(0|1|2|3|4|5|6|7|8|9)" to extract any single digit from the page. For regular expression, you can reference .NET Framework Regular Expressions
Friday, June 6, 2008 2:38 AM -
Thanks wavyknight12
Now about HTTP header ,, after add Extract HTTP header what to fill in HTTP name field?????
and about rgular expression can i put "(0|1|2|3|4|5|6|7|8|9)" in Regular expression field??????
and as i know that regular expression make a rule on a string like email field to be in this format [a@m.com] the @ and the dot ... same for date format [dd/mm/yy] the[/] so in regular expression field i can type the @ sign or the dot or / to extract every string in this format and find the result in webcontext ????
Thanks in advance
Friday, June 6, 2008 10:17 AM -
Refer back to wavyknight12's example. You would specifiy "Content-Length" for the "HTTP Name" field name. You would specify any value you like for the "Context Parameter" field (let's say you chose "length" as the name of the variable you want set). After the extraction rule completes, you would have a context parameter with name "length" and value "157".
Refer back to the link in wavyknight12's reply. The link include should tell you everything you need to know about Regular Expressions. But to answer you question, yes you would put "(0|1|2|3|4|5|6|7|8|9)" in the regular expression field (or any valid regular expression -- again, see the link for more details on regular expressions)
Thanks,
Rick
Friday, June 6, 2008 1:15 PMModerator -
thanks Rick
....
see this URL : http://www.iwebtool.com/http_headers
It's view Http header information like content type , lenght , location ., etc.......
when i type in Extract HTTP header --> Header name field Content-Length then Run my webtest ,,
it passed but it gave me different # than it displayed in http.://www.iwebtool.com/http_headers
but for the type it gave corret info ,, but it faild when i type Content-Location !!!.......
now ,,, when i extract this http header what the exact useful of it ?????
ok i can use its context parameter to validate it in another response ,,, but why to do this ????
and about Regular expression i tried and fill regular expression field with ["(0|1|2|3|4|5|6|7|8|9)" ] the webtest passed and in web test context the result was 3 .... how can i be sure of my result ???? and when i fill the same field with (@) expression the result is @ ...............
and about Regular expression may i need more to know about , and i opened the link wavyknight12 gave me ,, it give me an introduction then links ,, i donna if those links are useful ,.,,,
U know that i want just to extract this regular expression ,,,,,,
i want to know why we extract that ??? is that to support webtest ???? web test test's the funcutionality of the page and in those rules we support testing ???????
thanks in advance
- Proposed as answer by Matt Moss Friday, October 19, 2012 8:38 PM
Friday, June 6, 2008 2:54 PM -
The typical reason that you would extract data into the web test context is so that you can use it later by binding the value in the context to a parameter in a subsequent request.
A classic example would be a response that contains a sessionId in it. The subsequent requests may depend on the sessionID which could be different each time the test is run. You would extract the sessionID from a response (let's say to and context variable name "id") then bind that context parameter the value of a request-parameter of a subsequent request (let's say request2).
Regarding the content headers.... look at the response tab in the Web-test result view to see the exact headers that were returned by the request. Just select the request that you want to view details on in the top pane, then view all the information about the rquest in the bottom pane. One of the tabs is response... it will show you the exact headers that were returned by the response.
Thanks,
Rick
Friday, June 6, 2008 4:48 PMModerator -
Thanks Rick ....
about content header also the extract content -lenght not like the one that displayed in respons etab in web test result ..
and about Regular expression i tried and fill regular expression field with ["(0|1|2|3|4|5|6|7|8|9)" ] the webtest passed and in web test context the result was 3 .... how can i be sure of my result ???? and when i fill the same field with (@) expression the result is @ ...............
how can i be sure of my result ????
Friday, June 6, 2008 9:11 PM -
[[about content header also the extract content -lenght not like the one that displayed in respons etab in web test result ..]] ....
i run a webtest again and the extract content -lenght like the one that displayed in respons etab in web test result ..]] ....
....
But my miss understanding now in Regular expression ,,
Friday, June 6, 2008 9:23 PM -
Your regular expression says to match the first digit found in the response. The "3" must be the first digit that appears in the response body. You can verify this also by looking at the response body in the Web-test result viewer (just below where you found the response headers.
So, a match was found for the ExtractText rule and the value was placed in the context. This is the way it is supposed to work.
Saturday, June 7, 2008 3:08 AMModerator -
Hi Rick ,
You wrote : [A classic example would be a response that contains a sessionId in it. The subsequent requests may depend on the sessionID which could be different each time the test is run. You would extract the sessionID from a response (let's say to and context variable name "id") then bind that context parameter the value of a request-parameter of a subsequent request (let's say request2).] ,,,
How can i extract session id ??? by using custom extraction rule ????
or which built in extraction rule shall i use ????
thanks in advance
Sunday, June 8, 2008 8:29 AM -
and i want to extract querystring to use it in other requests ,,
example :
user name , ...etc ..
Sunday, June 8, 2008 2:37 PM -
Vagueraz:
It appears that you are asking the same (or at least similar) questions on multiple threads. For starters, you need to determine whether you need to extract these values for other request. Some things are already handled quite nicely in most cases by VSTS (such as HIDDEN values). Why do it if it's not needed?
You may want to look into some books or links to understand HTTP. Chuck mentions a few publications in his thread:
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=3006039&SiteID=1
There is also Ed Glas' blog with tons of stuff for VSTS
http://blogs.msdn.com/edglas/pages/content-index-for-web-tests-and-load-tests.aspx
And also debugging techniques.
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=3006039&SiteID=1
Good luck.
Monday, June 9, 2008 12:19 PM -
Hi Lewis:
Actually i got confused with extraction rules !!
i know what each built in extraction rule did ana where to fiend it , but i'm still in doubt how extraction Rule helps my webtest??
I mean i did not find a way to using as an example extracted session id or query string parameter value ...
I want asenario that i can get the use of extraction rule ....
thanks
Monday, June 9, 2008 12:47 PM -
-
Lewis ,,
Can u give me a senario ,,???
I mean : suppose that you extract querystring parameter for one field ,, then i want to know how to use this extracted value ??
thanks
Monday, June 9, 2008 2:12 PM -
Here is a link to the Web Test Walkthrough: http://msdn.microsoft.com/en-us/library/ms243183.aspx
It shows scenarios on how to use Validation Rules and Extraction Rules.
Monday, June 9, 2008 2:21 PM -
HI Group ,
In Our projects after the session time out expierd the system is redirect to login page and the following alert message is displayed [Session expired; Please login again ] , and the
URL is as an example :
http://umniah/ANANA/CmsSecurity/Sec_Login.aspx?Error=-100
what i want is to extract this Query string parameter Error= -100 and be sure that session
alert message [Session expired; Please login again] is displayed when the session time out is expeird in every system module page .......
Wednesday, June 11, 2008 9:00 AM -
Vagueraz:
You should post this question as a new thread since it does not pertain to the original subject of this thread. Also, you should mark the reponse that helped you as being helpful and as the answer.
Wednesday, June 11, 2008 6:38 PM -
hi,
i have a question related to this thread.
i want to extract a header from a response received. However my primary request has re-directs and hence i get 3 dependent requests. when i am trying to get the header text using ExtractHttpHeader I am getting the header value from the dependent response and not from the primary response. is there a way to capture response header from the primary request. I tried setting property ParseDependentRequest to 'false', but it didnt work.
Thanks for your helpWednesday, November 12, 2008 7:25 PM