How LoadRunner Makes Associations

About Loadrunner correlation 1. When do you
need to correlate Search in the content to get the corresponding value, and replace the static value in the form of a variable to send the correct request to the server. This method of dynamically obtaining the server response content is called association. In fact, the association is also a special parameterization, but it is slightly different from the general parameterization. The parameters of the general parameterization come from a file, a defined table, a result set written through sql, etc., but the parameters obtained by the association are A qualified and dynamic value returned by the server in response to the request 2. When do you need to do the association? To understand this problem, we must first know the process of the request and response between the client and the server. The request of the page After the server gets the request, it returns to the login page and dynamically generates a Session Id. When the user enters the username and password and requests to log in, the Session Id is sent to the server at the same time. If the Session Id is valid in the current session, Then return the successful login page, if it is incorrect, the login fails











During the first recording process, loadrunner recorded this value and wrote it into the script, but when it played back again, the client sent the same request, and the server dynamically generated the Session Id again. The request is wrong, in order to get this dynamic Session Id we use the association here.
So we come to the conclusion:
when a certain request of the client changes dynamically with the response of the server, we need to use the association. Of course, we should have a proper understanding of the test
project when recording the script , and know which requests need to be Using the dynamic values ​​of the server response, if we do not know which values ​​need to be associated, we can also record the script twice, and compare the script to find the part that needs to be associated, but it does not mean that all the differences between the two recordings are All points need to be associated, which needs to be analyzed in detail. Second, the automatic association of loadrunner parameterization The automatic association includes two mechanisms: one is that loadrunner prompts the user whether to associate by comparing the difference between the server responses during recording and playback, and the user can Create association rules, this function can easily allow us to obtain the parts that need to be associated, but there are also certain problems, such as: the association points detected by automatic association may not really need to be associated, which requires us to be more realistic. Judgment; some dynamic data that needs to be associated cannot be automatically associated, so manual association is required. Another is the automatic association rules that come with loadrunner. When recording a script, it will automatically create associations according to these rules . The steps for automatic association are as follows : 1. Turn on the automatic association option







For the two association mechanisms just mentioned, if the user wants to use the association rules that come with loadrunner to create associations, they need to enable the association rules in [Recording Options] > [Internet Protocol] > [Correlation], and select "Enable correlation during recording" , when recording scripts of these application systems, VuGen will automatically establish associations in the scripts. You can also add association rules in [Recording Options] > [Internet Protocol] > [Correlation] to achieve the purpose of automatic association.
If you need to automatically detect the parts that need to be correlated when replaying the script, you need to select "save correlation information during replay" and "show scan for correlations popup after replay of vuser" in [Tools]>[general options]>[Correlation] ”, when the script is played back, the Scan actionfor correlation window will pop up to search for correlation points.
2.
The process of recording the script and recording the script will not be discussed here
. 3.
If the recorded script has parts that need to be correlated, Then there will be an error when playing back the script
4. The system automatically pops up the detection association dialog box, or manually starts the association detection dialog box
If "save correlation information during replay" and "show scan for correlations popup after replay of vuser" in [Tools] > [general options] > [Correlation] are selected, then the "Scan action for correlation" will pop up automatically after the script is played back. ” window, click “yes” to automatically search.
If the above settings are not selected, you can also press CTRL+F8 to start the association automatic search.
5. Check the association points detected by the system for association settings.
If there is a difference between recording and playback, loadrunner will List the content that needs to be correlated in "Correlation Results", click a piece of content that needs to be correlated with the mouse, click "Create Rule", the system will display the rules for obtaining the current data, click "yes" to complete the creation of the rule, and at the same time A web_reg_save_param function
has been added to the view script. You can also click the [Correlate] button to create associations, one by one, or press [Correlate All] to let VuGen associate all data at one time.
Note: Since Correlation Studio will find all the changed data, but not all data needs to be correlated, it is not recommended to use [Correlate All] directly.
6. Play back the script to check the correctness of the
association After the association is created, play back the script to check the correctness of the association.

3.
 Manual association The process of manual association is roughly as follows:
  Step 1: Record the test script and record it twice
  Step 2: Use the WinDiff tool Find out the difference between the two scripts and determine whether an association is required
  Step 3: Determine the position to insert the association
  Step 4: Use the web_reg_save_param function to manually establish the association in the VIEW TREE
  Step 5: Use the associated data in the script to replace it with parameters
  Step 6: Verify the correctness of the association The
  following details Introduction: The
  first step: record the test script and record it twice
  . Needless to say, the same operation, record two copies and save them separately. The   second
  step: Use the WinDiff tool to help find the data that needs to be associated.
In the copy script, click [Tools] > [Compare with Vuser…] of VuGen, and select the first script.
  2. Then WinDiff will be opened, and two scripts will be displayed at the same time, and the differences will be displayed. WinDiff will mark the differing scripts with a whole line of yellow, and show the actual difference text in red font. (If you don't see the red font, please click [Options] > [View] > [Show Inline Differences]).
  Look at the differences between the two scripts, each of which may be a link that needs to be made.
  Note: The difference of the lr_thik_time part can be ignored
  . After finding the different part, copy it, then open the Recording Log or Generation Log, press Ctrl+F, paste the content of the difference part in the search window, click Find to find, and view the information of this part , confirm whether it is the client's request information or the server's response information
  If it appears in

 
RequestHeaderForTransactionWithId3EndedRequestHeaderForTransactionWithId3Ended
 

In this part, it proves to be a request sent by the client. Here, the
  general associations that do not need to be associated appear in ****** Response Header For Transaction With Id 7 ****** and *** *** Response Body For Transaction With Id 7 ****** section.
  After finding this information, you need to record the following information:
  a. Record the content before and after the
different data b. Record the location where the different data appears, whether it is Header or Body
Step 3: Confirm the location of the insertion association
  We are in the log The location of the different points of the two scripts is found in the script. According to this location, we determine which request is generated after, that is to say, which request is generated to locate the response of the different point, and find the function of this request. Location, we know where to connect.
  In general, the associated function can be written before the function that makes the request.
  Step 4: Insert the associated function
  Before inserting the associated function, we first introduce the associated function web_reg_save_param
  An example of the web_reg_save_param function:
web_reg_save_param ("sessionid",
  "LB=Session_id:",
  "RB=;",
  "Search=Body",
  LAST);
  here we only introduce the meaning of several commonly used parameters
  Syntax: int web_reg_save_param(const char *ParamName, <list of Attributes>, LAST);
  Parameter description:
  ParamName: The parameter name of the obtained dynamic content
  list of Attributes: Other attributes, including: Notfound, LB, RB, RelFrameID, Search , ORD, SaveOffset, Convert, SaveLen. Property values ​​are case-insensitive
  LB( Left Boundary ) : Returns the left boundary string of the message. This attribute is required and is case sensitive.
  RB( Right Boundary ): Returns the right boundary string of the message. This attribute is required and is case sensitive.
  Search : Returns the search scope of the information. Can be Headers, Body, Noresource, All (default). This property is optional.
  So how do you insert this associative function?
  1. Switch vugun to view tree mode
  2. In the list on the left, find the function that made the request in the previous step, click "right button" and
  select "insert before"
  3. In the "add step" dialog box that pops up, "find" Enter "web_reg_save_param" in "function", click "ok"
  and enter in "parameter name", the name of the associated function, it is best to have a meaning here, "sessionid"
  is entered in "left boundary", the different point strings just recorded A few characters to the left of the , define the left boundary, Session_id:
  In "right boundary", enter the characters on the right of the different point strings just recorded to define the right boundary;
  in "search in", select "body" and
  click "ok"
  4. Return to script editing mode Next, check whether the function is inserted correctly . You
  should see before the function that sends the request:
web_reg_save_param ("sessionid",
  "LB=Session_id:",
  "RB=;",
  "Search=Body",
  LAST);
  Step 5: Replace the relevant data in the script with parameters
  If the parameters of the request are as follows, replace the dynamic value returned by the original server with { sessionid }:
web_submit_form("login.php_2",
  "Snapshot=t2.inf",
  ITEMDATA,
  "Name=login", "Value=wangjin", ENDITEM,
  "Name=password", "Value=wangjin", ENDITEM,
  "Name=Session_id","Value={ sessionid } ", ENDITEM,
  "Name=Submit ", "Value=Login", ENDITEM,
  EXTRARES,
  "URL=/media/images/border_bg_l.gif", ENDITEM,
  "URL=/media/images/header_bg.gif", ENDITEM,
  "URL=/media/images/th.gif", ENDITEM,
  LAST);
  Step 6: Verify the correctness of the association
  Playback the script to verify the correctness of the association .

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324938784&siteId=291194637