Get Knowledge from Video instead of Content:

Monday 30 January 2017

JMeter - Config Element - "User Defined Variable"

User Defined Variable config element is used to declare and defined the variables which are used in the JMeter script. Some variables like application URL, port, etc. are generally defined in User Defined Variable element. 

Ideally, this element is placed under the Test Plan if you need to define Global variables. If it is placed under Thread Group then the variables scope will be local. 


Once the Test Plan and all user-defined variables have been processed, the resulting set of variables is copied to each thread to provide the initial set of variables.



Note: 
1. If  User Parameters, Pre-Processor or Regular Expression Extractor defines a variable with the same name as one of the UDV variables, then JMeter will replace the initial value defined under UDV, and all other test elements in the thread will see the updated value. 
2. If there is more than one Thread Group, then it is advisable to use different names for different values, as UDVs are shared between Thread Groups. 
3. If there is more than one Thread Group, then the reference variables can be defined under the Test Plan. Because, the variables are not available for use until after the element has been processed once.
How to add "User Defined Variable" config element?
You can follow steps to add User Defined Variable:
1. Select "Test Plan" node
2. Right click on "Test Plan" node
3. Mouse hovers "Add"
4. Mouse hovers "User Defined Variable"
5. Click "User Defined Variable


How to remove "User Defined Variable"?
You can follow steps:
1. Select "User Defined Variable" node
2. Right click on "User Defined Variable" node
3. Click "Remove" (Mouse) or "Delete" button from the keyboard
4. Click "Yes"

What are the attributes of "User Defined Variable"?
"User Defined Variable" has attributes:
  • Name: To provide element name
  • Comments: To provide arbitrary comments (if any)
  • Name: Declare the name of the variable which will be used in the script. 
  • Value: The value which needs to be passed in the script against that variable. 
  • Description: This is an optional field to describe the purpose of the variable. 
How to use the user-defined variable in the JMeter script?
You can use the defined variable in the same way as a regular expression or other runtime element variables are used like ${.....}. 
Example: If you defined 'host' variable in the User Defined Variable element then it can be used as ${host} in the script.

Next Topic:
Apache JMeter - "Timer" Element

Previous Topic:
Apache JMeter - "Simple Config Element"

Related Topics:

No comments :

Post a Comment