当前位置:网站首页>Performance test - LoadRunner obtains the return value and user-defined parameters (parameter operation)

Performance test - LoadRunner obtains the return value and user-defined parameters (parameter operation)

2022-06-23 22:32:00 FutureTester

example

Mobile terminal operation ,A Added an event ( Return results : event id, for example :1),A At this time, you need to get the newly generated events id, And pass it as a parameter , To report this incident to B( Return results : event id unchanged , step id It's an event id Add 1),B You need to get the events returned from the report id And steps id To handle this matter .

One method :

If two return id All in loadrunner The return result shows (view-Test Results perhaps Tree You can view ):

You can use web_reg_save_param The function passes through the left and right boundary values , Locate what you need id, And then assign it directly to a variable , Then the next step is to call this variable directly

for example :

web_reg_save_param("sid",
"LB=aaa\":",
"RB=bbb",
LAST);

The above example means that the left boundary aaa”: And the right border bbb The middle value is assigned to the variable sid. Be careful : Escape when there are double quotation marks on the left and right boundaries , Escape character :\

Loadrunner Cannot call directly in sid, With braces , for example :{sid}

Two methods :

If two return id Step 2 id be not in loadrunner The return result shows :

At this time, we can use the mobile packet capturing tool to assist us in testing , Find two id The relationship between .

As the title says : step id= event id+1

At this time, we can find out the event through a method id The assignment is sid, And then through lr_output_message Function print out :

for example :

 lr_output_message ( "id: %s", lr_eval_string ( "{sid}" ) );

And then through atoi Function to sid Add 1

for example :

atoi(lr_eval_string("{sid}"))+1;

Finally, directly atoi(lr_eval_string("{sid}"))+1 Just assign the value of to a variable

Be careful when defining variables

All declarations should be placed in front of the script

Knowledge point

1、atoi function : String reshaping

2、 Encountered double quotation marks to escape when getting the return value

3、web_reg_save_param The return values obtained by the function are all strings , If you want to perform an arithmetic operation , You need to type the obtained value now

原网站

版权声明
本文为[FutureTester]所创,转载请带上原文链接,感谢
https://yzsam.com/2021/12/202112121458449062.html