LoadRunner Correlation with web_reg_save_param_regexp
Do you have a correlation which you can’t solve because the values of the left and right boundary are dynamic? Correlation is an essential part of performance test scripting and there are plenty of different challenges with correlation. Imagine having a value of “GraphA123567EndGraphA” and the goal is to correlate 123567
From the example above, the left and right boundaries would be “LB=GraphA” “RB=EndGraphA”
What if the word GraphA is dynamic and can be anything from GraphA-GraphZ?
There is a solution at hand!
Using web_reg_save_param_regex will allow the user to grab a correlation value using dynamic left and right boundaries. This function uses the power of regular expressions, below are a few examples:
Solution: web_reg_save_param_regexp(“ParamName=CorrValue”, “RegExp=\“Graph[A-Za-z]\”, \“([0-9]+)\”, \“EndGraph[A-Za-z]\””, LAST);
Correlate the values from a drop down list of a form
Source: dropdown >>> red, blue, green
Solution: web_reg_save_param_regexp(“ParamName=ColourList”, “RegExp=option=[0-9]+>([A-Za-z]) ”, “Ordinal=All”, LAST);
Correlate up till the end of 642
Source: J\u002blsGd3zj1qdP\u002bvk0vDRaKyJFde5tCa6spDEy08SNab1hP8j5GTs4j6\u002f\u002bTqOwvxMHEQZLWd\u002btu8NlHJrVAarIQ==|634998513832503642 ];
Solution: web_reg_save_param_regexp( ParamName=SecurityString , RegExp=\ ([A-Z0-9a-z\\\\+]+==\\|[0-9]+)\ \\]; ,LAST);
Correlate only “634998513832503642” Source:
web_reg_save_param_regexp( ParamName=SecurityString , RegExp=\ [A-Z0-9a-z\\\\+]+==\\|([0-9]+)\ \\]; , LAST);
So what is a Regular Expression?
Also known as regex, a regular expression is a search string which enables matching of a string. Think of it as an advance searching function which can pick out values from a string of multiple characters.
Examples of regex:
- \d matches a single digit
- \w matches a single word (including alphanumeric characters and underscore)
- [A-Z]+ matches any word which is upper case
- [a-z]+ matches any word which is lower case
- [0-9]+ matches any numeric value
There are other alternatives to web_reg_save_param_regexp. However these functions are limited and not as flexible.
LB/DIG RB/DIG – # will be a wildcard for a numeric value“session_id_##”
- Adding LB/IC/DIG will ignore case
- “LB/IC/DIG=session_id_##=” (e.g. Session_id_20)
LB/ALNUM or RB/ALNUM ^ will be a wildcard for an alphanumeric value
- ALNUMIC – ignore case
- ALNUMLC – match only lower case
- ALNUMUC – match only upper case
- If there is a dynamic value for a boundary e.g. “session_id_2” (3,4,5)
- SaveOffSet = 2 (to cover “2=”)
- Web_reg_save_param(“SessionID”, “LB=session_id_”, “RB=\””, “SaveOffSet=2”, LAST);
- PERL based
- LR 11 does not support multiple capture groups however this is now supported in LR 11.52 (example below)
Example Multiple Capture Groups
Source: rows :[[“NW,RO,RA , DLY , 10/07/2011 , 10/17/2011 , 10/01/2011 , RA , Y , FR , AMEA , AC , 1945 , 50 , 50 , AC 100IOSH-08 , UserDefined , 10/07/2011 , Reassigned
In Example Multiple Capture Groups :
Source: rows”:[[“NW,RO,RA”,”DLY”,”10/07/2011″,”10/17/2011″,”10/01/2011″,”RA”,”Y”,”FR”,”AMEA”,”AC”,”1945″,”50″,”50″,”AC 100IOSH-08″,”UserDefined”,”10/07/2011″,”Reassigned”…”
and Regularexperssion you wrote as below
__ I have few questions __
1. you had used \r\n in above regexp, but is for new lines. as per the source code in single line.
2. ^ is for match any thing expect in regexp and * is for match from Zero (0) to all.
I am trying to capture a value between ;90004; and style=
90004 keeps changing depending on the selection of data from data file with each iteration.
The full string is ;90004;ea98f132-edeb-4ebe-8efe-684cb949c11b style=
Could you please help.
I tried the following
// RegExp=90004;(.*?)\ \\ \\ \\ style ,
// RegExp=#####;(.*?)\ \\ \\ \\ style ,
RegExp=#####;(.*?)\ \\ \\ \\ style ,
Any help is much appreciated.
I have update 11.52, but am not successful in using multiple capture groups. Are there additional options needed when trying to use this strategy. I tried variations on the group setting, but it does not look like you can capture more than one at a time to put in a variable. At least, I could not do what is proposed above. I just opted for two variables with the same reg exp, but the portion I am interested in placed in parentheses. And I could not find a reference for this in the What s new section of the help for 11.52.
How would you correlate the last word of a question when you have different questions? I am trying to correlate the last word of the sentence because that is an answer for each question. There are several questions but the webpage will ask one at a time. So far what I have done:
Correlated the questions.
Tried to correlate last word by using space in left boundary and “?” as right boundary. This is because the questions will be different and in a different lengths. The Right boundary will always be “?” because these are questions.
Any help would be appreciated.