Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Definition of parameters and variables Summary of the application of parameters and variables in the scope of parameters and variables

2025-01-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/03 Report--

Parameters and variables

Definition of parameters and variables

How to write variables and parameters

Scope of parameters and variables

Summary of the application of parameters and variables

Parameters and variables

The string that uses {} by default in Vugen is called parameter, and the parameter can be called directly in LoadRunner.

Parameters cannot be written anywhere in the LoadRunner script

The biggest difference between a parameter and a variable is that the parameter can only be applied through double quotes, while a variable becomes a string if it uses double quotes.

So when using lr_eval_string (), it is also called in double quotes.

For example:

Web_submit_form ("login.pl_2"

"Snapshot=t3.inf"

ITEMDATA

"Name=username", "Value= {uname}", ENDITEM

"Name=password", "Value= {uname}", ENDITEM

"Name=passwordConfirm", "Value= {uname}", ENDITEM

"Name=firstName", "Value= {uname}", ENDITEM

"Name=lastName", "Value= {uname}", ENDITEM

"Name=address1", "Value=shenzhoutest1", ENDITEM

"Name=address2", "Value=shenzhoutest1", ENDITEM

"Name=register.x", "Value=45", ENDITEM

"Name=register.y", "Value=4", ENDITEM

LAST)

Lr_output_message ("uname:% s", lr_eval_string ("{uname}"))

Parameter definition

Commonly used parameters are created using Parameter List. This type of parameter does not need to be defined. Just make sure that the parameter name in the script is the same as that in the parameter list.

Custom parameters can also be used, which requires the lr_save_string () function to save a string in a parameter.

Variable definition

The variable definition must be placed at the beginning of the script and before the system function, otherwise the script will run with an error.

Parameters can be used in system functions. In most cases, parameters can directly replace the contents in double quotes of system functions.

Variables belong to C language and cannot be used directly in system functions.

Examples of parameters and variables

Web_submit_form ("login.pl_2"

"Snapshot=t3.inf"

ITEMDATA

"Name=username", "Value= {uname}", ENDITEM

"Name=password", "Value= {uname}", ENDITEM

"Name=passwordConfirm", "Value= {uname}", ENDITEM

"Name=firstName", "Value= {uname}", ENDITEM

"Name=lastName", "Value= {uname}", ENDITEM

"Name=address1", "Value=shenzhoutest1", ENDITEM

"Name=address2", "Value=shenzhoutest1", ENDITEM

"Name=register.x", "Value=45", ENDITEM

"Name=register.y", "Value=4", ENDITEM

LAST)

Lr_output_message ("uname:% s", lr_eval_string ("{uname}"))

The writing of variables

Char blog [100]

Strcpy (blog, "URL= http://rwxxtest.blog.51cto.com/");

Web_url ("51ctoblog", blog

LAST)

Parameter writing method

Lr_save_string ("http://rwxxtest.blog.51cto.com/"," 51ctoblog ")

Web_url ("51ctoblog"

"URL= {51ctoblog}"

LAST)

Scope of parameters and variables

Parameters can be used in any Action in the script, and variables are local, and errors will occur if you exceed the Action that defines variables, but global variables can be defined in global

Exchange of parameters and string variables

Char * str

Lr_save_string ("Welcome to a series of performance testing training courses for me to think about", "parame"); / / assignment

Str=lr_eval_string ("{parame}"); / / value

Lr_output_message (str); / / output

Variable stores parameter name

Char * str1

Str1 = "{parame}"

Lr_save_string ("Welcome to continue watching and let me think about the teacher's series of performance testing training courses", "parame")

Lr_output_message ("parame:% s", lr_eval_string (str1)); / / get the parameter that the variable points to.

Output according to a certain format

Lr_save_string ("Let me think about a series of performance testing training courses for teachers", "rwxxtest")

Lr_output_message ("% s", lr_eval_string ("Welcome to {rwxxtest}"))

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report