User defined variables in JMeter

Consider a situation where you have several HTTP requests with various parameter settings but identical URLs. You might want to change the URL in the future. If there are hundreds of URLs, you will have to modify each one, which will take a lot of time and be mistake prone.

In these circumstances, JMeter's user defined variables are used.

Follow below steps to add User defined variables:

  1. Create a Test plan, add Thread group, Sampler, listener. Also add user defined variables.




  2. Enter blazedemo.com in server for sampler 1 as shown in image:
  3. In the second sampler, I want to test '/login'. So, I need to specify '/login' as path in HTTP request. And there are two ways to do it, I can either hard-code it as shown in below image or move to separate variable.


    The hard-code option is not good if you have hundreds of samplers in Test-Plan

  4. In the user defined variables, enter variable name and path.
  5. In the sampler2 add variable name in path as ${variable_name}
    here it will be ${login}


    Now run and check if it is working properly.


Comments

Popular Posts