Add LoadRunner11 skills of scripts small request header + + define the variable response content conversion garbled print

First, the addition request header

There are some interfaces need to request permission to send authentication, verification (run-time without request header script, the interface may report 401, etc.), so it is necessary to add the corresponding request request header in the script. Note: prior to the request header for an add request, comprising url type, class Submit request.

Second, the definition of variables

The above-mentioned request to add the issue head, such as configuring the gateway do need to go through the certification authority, in order to log in to access the system when the system is properly deployed, so each interface request will need to add the request header! In above figure, including access-token, this token is valid is present, more than 30 minutes will fail; when the token fails, the new token values ​​have to take out the replacement token script failed before running the script, substitutions, then a manual very time-consuming; this can be resolved by reference to the definition of variables!

As shown, each transaction script previously defined variables a, b and assigned to a string, and a reference value of b in the subsequent request header script; through the definition of variables, when the subsequent token fails, simply replace the variable the value of a can.

. 1 char * A = " 1b284eb3ec923775528440a631af5868 " ;    # define variable A 
2 lr_save_string (A, " b " );                       # use lr_save_string () will be "" end of the string (a) is saved to the parameter b 
. 3 lr_output_message (lr_eval_string ( " b} { " ));      # lr_eval_string () for all occurrences of the parameter b with its current value in place; lr_output_message () printing function, print the value of b

Third, in response to the contents of garbage is converted into Chinese

The previous articles have mentioned LoadRunner11 interface issues in response to the contents of garbled when inserting the checkpoint, the log can not determine whether the test results in line with the expected results. So you can look garbled content into Chinese and prints, you can see real results directly in the log.

 

 

 Text tips Checkpoint knowledge please refer to another blog post , but more description here, only gibberish content into Chinese code:

1  // looks into utf8 encoding target, into the variable test_find in
 2      lr_convert_string_encoding ( "Rou Kuiqiu prostitutes",
 . 3          LR_ENC_UTF8,
 . 4          LR_ENC_SYSTEM_LOCALE,
 . 5          "text_find");
 . 6  
. 7  // the content becomes test_find string, the presence of find the variables
 . 8      lr_save_string (lr_eval_string ( "text_find {}"), "find");
 . 9  
10  // print find the value of the variable
 . 11      lr_output_message ( "checkpoint translational distortion content =  % S", lr_eval_string ( "{} find" ));

Actual operating results:

Guess you like

Origin www.cnblogs.com/dnjiang/p/12532737.html