Today, I will explain - what is LoadRunner correlation and how to perform it.

In my humble opinion, correlation is the key concept of LoadRunner. So, strong understanding of correlation is mandatory requirement for any test engineer, if he plans to be LoadRunner professional or even guru :) Example from a real practice: I recorded LoadRunner script for a web server, which contained two special fields - timestamp and checksum: web_submit_data("rms.jsp", "Action=http://eprumossd0010:8400/RMS/jsp/rms.jsp", "Method=POST", "RecContentType=text/html", "Referer=http://eprumossd0010:8400/RMS/html/testFramework.html", "Snapshot=t4.inf", "Mode=HTML", ITEMDATA, "Name=TIMESTAMP", "Value=1192177661211", ENDITEM, "Name=CHECKSUM", "Value=715E19300D670ED77773BBF066DAAAE2866484B8", ENDITEM, // others parameters ... LAST); Every time a client web browser connects to web server, server gets current time stamp, calculates checksum and sends them to client. These two fields are used to identify a current session. In other words, the pair of timestamp+checksum is analog of session ID. The scheme of this interaction is the following:

Where is the problem? Let's replay the recorded LR script. The problem occurs when I try to execute my recorded script. Web server checks its current time with a time stamp, sent by client. If client's data is out-of-date or incorrect, then server returns an error: The parameter "CHECKSUM" is not found or has invalid value. There is the scheme for this interaction:

The algorithm of manual correlation is the following: 1. containing the dynamic value. Correlation can be done with 2 ways: 1. Now. 2. it does not work. 3. 5.e. Automatically Manually I will describe auto-correlation in the future posts. Special parameter will be used instead of dynamic value. Sometimes. Find a dynamic value to capture. It must request new data. returned from server. Manual correlation is a choice of real LoadRunner engineer. Find server's response. For now. Capture the dynamic value. Check changes. This can be done using a correlation: The definition of correlation is: Correlation is the capturing of dynamic values passed from the server to the client. I can say that this is not ideal solution. instead of hard-coded values. So. hard-coded) values for times tamp and checksum. I will describe each step in details: . let's start investigating a manual correlation. It's a kind of "must have" knowledge! Well. Replace every occurrence of dynamic value in script with the parameter. or works incorrectly. LR script should process dynamic data.Client cannot re-use old (i. 2. 4.

"Value=A38E9002A41". please enable extended logging from "Vuser / Run-Time Settings. 2. Open Replay (Execution) log and find server's response. "Name=CurrentMonthID".. my dear reader :) Tips: Look through the source code of recorded script. CheckSum. It's obvious. etc) indicate about potential correlations. . This highlighting means that lines (parameters values) change from run to run. ENDITEM.": Then execute script. and will not work from 1st May! So.. most probably. Tips: Execute your script with enabled run-time viewer (menu "Tools / General Options.. these values should be correlated.. that you recorded this script: "Name=SessionID". open menu item "Tools / Compare with Scripts. and different IDs . Find a dynamic value to capture I recommend to record and save two equal VuGen scripts. Timestamp. that your script will work correctly during the April (4th month is April).1. that SessionID should be correlated. What about CurrentMonthID parameter? Second recorded script can contain"Value=4" too... Imagine. After that.all of they are potential candidates to be correlated. Tips: Check Replay (Execution) log carefully." and you can compare both recorded scripts in WDiff: The differences are highlighted by yellow. "Value=4". ENDITEM. / Display"). containing the dynamic value Before script executing. And it's possible. Errors can be there. Tips: Sometimes. So. SessionID.. "Session timeout". comparing of two scripts cannot detect dynamic values. which contains dynamic values of TIMESTAMP and CHECKSUM: . Any shown errors ("Page not found". The widespread reason of script's errors is an absence of correlations. Find server's response. be careful.

"Method=POST".Action. select "Body" to view body of server's response (4).jsp". As result. Open Tree view (menu "View / Tree view"): Then:    click "View recording snapshot only" btn (2).web_reg_save_param. . 13th line of script will be opened: web_submit_data("generateChecksum.jsp page contains dynamic values which should be correlated.jsp". where server sends both dynamic values. and select "Create parameter": After that you will see the message box: . select value of first dynamic value (checksum). Also. they use the same function . Now.. containing timstamp's and checksum's values. "RecContentType=text/html". This means that server's response for generateChecksum. right-click.c (13). you will see recorded values of CHECKSUM and TIMESTAMP (5). "Action=http://eprumossd0010:8400/RMS/jsp/generateCh ecksum. This is 13th line . Double click the line. select generateChecksum.jsp page from tree view (3). I start from: o Automatic capturing from Tree-view..Great! Now we know. that returns these values. Capture the dynamic value I will show two ways how to capture a dynamic value: o Automatic capturing from Tree-view o Manual from Script-view These ways are similar enough. 3. And we found the step.

I click "No" btn.setChecksum(\"". "RB=\"". 3. Actually. "Ord=1". There are many attributes of web_reg_save_param function. "Ord=1". To not replace all occurrences. "IgnoreRedirections=Yes". found between left and right boundaries. 2. The function finds the left boundary (window. "LB=. it captures a dynamic value. press "Yes" btn. LAST).parent. OK. "IgnoreRedirections=Yes". It requires strong knowledge on this function and its parameters. web_reg_save_param function finds and saves a text string from the next server's response. we capture the value between first left boundary and left one.setChecksum(") and after that it finds the right boundary ("). that "Search=Body" means search in a body of server's response. Ord attribute indicates the ordinal position of captured value. It's very interesting :) Note: the capturing of TIMESTAMP parameter is similar.") in script. It's more preferable to replace occurrences one by one with "Search and Replace" dlg. In the example (Ord=1). . "Search=Body". o Manual capturing from Script-view. Return to Script-view ("View / Script View") and see changes. will be saved to WCSParam_Text1 parameter. LAST). There are new lines. inserted before generateChecksum.. It can lead to incorrect results.. "Search=Body". In this example. The string. For example. "RB=)".I would prefer prmCheckSum and prmTimeStamp to WCSParam_Text1 and WCSParam_Text2. If you want to replace all occurrences of dynamic value ("715E19.parent. It generates the following code: // [WCSPARAM WCSParam_Text2 13 1192177661211] Parameter {WCSParam_Text2} created by Correlation Studio web_reg_save_param("WCSParam_Text2". Easy to guess. press "No" btn. web_reg_save_param function will save the captured value into WCSParam_Text1 parameter. ". Tips: I recommend to not replace all occurrences of dynamic value. in my example . I recommend to study Help on web_reg_save_param function.jsppage: // [WCSPARAM WCSParam_Text1 40 715E19300D670ED77773BBF066DAAAE2866484B8] Parameter {WCSParam_Text1} created by Correlation Studio web_reg_save_param("WCSParam_Text1". "LB=window. In other words. and I do not want to duplicate HP's Help :) Tips: I recommend to rename default parameter (WCSParam_Text1.You can create parameter for dynamic value. "RelFrameId=1". this method consists in a manual writing of web_reg_save_param function. "RelFrameId=1". etc) to something sensible.

"Value={WCSParam_Text2}". "Name=UserID".jsp". Why it is important? Imagine. ENDITEM. It may be wrong! OrderNumber can be static value and be equal to 125.. ENDITEM. "Method=POST". "Value={WCSParam_Text1}". "Value=125". "Name=UserID". "Mode=HTML". ENDITEM. "Name=OrderNumber". Check changes After above manipulations.. . "Value={WCSParam_Text1}". our script will look like: web_submit_data("rms. "Value=125". "Name=OrderNumber". "Value={WCSParam_Text1}". "Referer=http://eprumossd0010:8400/RMS/html/testFramework. "Action=http://eprumossd0010:8400/RMS/jsp/rms. // others parameters . Now.jsp". ENDITEM. and perform replacing of all occurrences of its value ("125").")... The statement "{WCSParam_Text1}" means "get value of WCSParam_Text1 parameter". So. then it will produce the code: web_submit_data("somepage". ITEMDATA.4.. LAST).. while UserID may change. Open "Search and Replace" dlg ("Edit / Replace. .inf". "Name=TIMESTAMP". Replace every occurrence of dynamic value in script with the parameter This is not difficult step. that you have the following code: web_submit_data("somepage". If you create parameter for UserID. "RecContentType=text/html".. "Name=CHECKSUM". current algorithm is: o when server returns different values of CheckSum and TimeStamp o then web_submit_data captures and places them into WCSParam_Text1 and WCSParam_Text2 parameters o after that we use {WCSParam_Text1} and {WCSParam_Text2} get current values of parameters and use them in scripts Let's run our modified script and see results of capturing from server's response: These are values. We have to perform last step: 5.html". And replace one-by-one hard-coded values with a parameter. which are sent to a server by a client: . "Snapshot=t4. I assume that you replace all needed occurrences of hard-coded values..

lr_output_message("Value of WCSParam_Text2: %s". Let's we have created VuGen script. which emulates the one user: The problem: script runs correctly in VuGen for one user. This happens since we recorded the VuGen script for the specific user: I marked "username" and "password" . I'm going to demonstrate some tips and uses of them. but it fails for several concurrent users. lr_eval_string("{WCSParam_Text1}"))... use the following statements: lr_output_message("Value of WCSParam_Text1: %s". he result is: Parameterizing is a powerful thing in LoadRunner! Now. lr_eval_string("{WCSParam_Text2}")). Execute script again. imagine the following situation. Great! We have just correlated our script and it is working now! Tips: To get/debug a captured value of parameter. Well.You can see that dynamic values are saved to parameters and their values are substituted instead of parameters in scripts.

and others. It contains interesting possible types. even XML. dear friend? :) But where can we specify the real values for our parameter? How to configure it? Let's continue. isn't it. I hope.. Wow! the value "load1" will be changed with a UserName parameter: We have just added the new parameter! It's wonderful.. So. Name the new parameter as "UserName" and click OK btn: Please. Random number. Application under test (AUT) does not allow several sessions of the same user. . Implementation: 1. pay attention to "Parameter type" combobox. Right click on a value we want to parameterize (in our case this is a username ."load1") and select "Replace with a parameter"menuitem: 2. I will have a chance to describe parameter types later. In any case.parameters and values with red lines.. it depends on the opinion of the blog readers :) 3.. Iteration Number. such as: "Date/Time". I will not describe them in the present post. he gets an error: The solution: to parameterize the VuGen script. if second concurrent VuGen user logs in to application.

You can: o "Restore original value (load1)" In other words. Here. Right click on the just added parameter and select "Parameter properties": By the way. "load1. "Replace All" will produce incorrect link . Tips: Please. use this feature carefully. . rollback your changes o "Replace more occurrences" This menuitem will find for the initial string ("load1") in the script and will propose to replace it with the new parameter ({UserName})."http://server/{UserName}.htm" link in the script.4. but user.htm" is a name of page. let's there is "http://server/load1. For example. this menu allows others operations with parameters.

how the parameter will be changed against interations and users o and other different settings.dat) and edit its content in the Notepad or Excel. topic "Data Assignment and Update Methods for File/Table Parameters". . MS Excel is useful if file contains values for several parameters. There are explanations with examples which describes .. "Parameter properties" will be shown: 6. Tips: You can open dat-file (UserName.5. Tips: I recommend to read the LR Function Reference. It contains the excellent table describing Update and Data Assignement methods ("Update value on" combobox and "Select next row" combobox correspondingly).what settings should be applied for your case. You can here: o specify the type of the parameter o create the pool of values for any parameter (add new values for any parameter) o specify. This dialog is a "heart" of any parameter..

etc. that's exactly the same we need.In the issue. .) update method ("Once") and data assignment method ("Unique"). the filled dialog will look like: These settings specify: o o the list of values to be used ("load1". "load2". "John21". The combination means: "The unique value assigned in the first iteration is used for all subsequent iterations of the Vuser" So.

Each user had his own session. we have to create a scenario.g. 3. note: You can store parameters in the one dat-file. . Parameterizing allows decrease maintenance cost.. Please. In this post I use two dat-file. Just for demonstration. all concurrent user logged with their unique login/password combination. If application under test is changed. Ooh! Everything is completed I hope.. Separating test data from the code is a good idea. but 100 tests for each user Supporting of tests is a real pleasure :) To add new user. Now. one test should be updated for 100 (e.) users. The summary: Parameterizing allows simplify load/performance testing: 1. 2. And using one data-file is very convenient. After that I perform the similar procedure (steps 1-6) for "Password" parameter: o o 8. we added parameters for specific information (username & password) and used the one script for all users. add parameterized LoadRunner VuGen script and execute it :) Here you are: All transactions passed.7. As for me. Instead of writing a separate LoadRunner VuGen script for each virtual user. In other words. a test has to update dat-files only. I prefer this way.

Sign up to vote on this title
UsefulNot useful