When you want to define a JMeter function, you can easily write it manually with some simple functions (like __Random, __RandomString, __time, etc.). But in most of the other cases, you have to use the Function Helper Dialog to define correctly the function without any issue related to the syntax, or wrong the order of the parameters.

What features which the Function Helper Dialog deliver? How to use it effectively and exactly? Please check out this post to answer those questions (Please note the Function Helper Dialog in this post is suitable for version 5.0 and higher).

There are some ways to open the Function Helper dialog:
– Using menu Option > Function Helper Dialog
– Using shortcut: ⇧ ⌘ F1 (MAC) or Ctrl + Shift + F1 (Windows)
– Using the “notebook” button in the button  toolbar
dialog-button.png

Let’s take a look into the screenshot of the Function Helper

dialog-overal.png

I’ve marked the number to the corresponding place in the dialog, now we will go through all of them and see what they are…

1. Functions List

This dropdown list provides the list of all functions which JMeter supports, and also all Plugins Function if you installed the Custom JMeter Functions. And this is the first thing you need to do with the dialog, select one of function you want to use in the dropdown list, it will load the corresponding Function Parameters in the table below.

dialog-2-functions-list.png
I’m choosing the __RandomDate function

2. Help button

In case you’re very new with JMeter, you don’t know what that function used for? Or you might get familiar with JMeter function, but you’re confused about some functions you never use before. What is the purpose of this function? How to use it? These questions pass through your mind. Don’t worry, Help button might help you in this case.

Just select the function in the list, then click the Help button. It will lead you to the JMeter official site and point to that function description. For example, I’m selecting the __RandomDate function, and click Help let me access this site: https://jmeter.apache.org/usermanual/functions.html#__RandomDate

You can find some useful information there, such as the purpose of the function, how many required parameters and which value needs to be inputted for each parameter, etc. Usually, they will also provide some examples of the way to use that function.

Note: Help button will not work correctly if your function is one of Plugin Function.

3. Function Parameters

One of the most important things in the Function Dialog, that is Function Parameter table. And this table is displayed depending on the selected function. Each function has different parameters, some functions have only one parameter, some other has more than one, and even some functions have no parameter.

dialog-3-one-param.png
Example of only one param
dialog-4-multiple-params.png
Example of multiple params
dialog-5-none-of-param.png
None of the parameters

In the Function Parameters table, the left column provides a brief description of the parameter, and the right column is where you write in the value for that argument.

If the function using at least one parameter, you should pay attention, some of them are required, and some of them are optional, or all of them are required, and even all of them are optional. Based on that, you must input the value for the required parameter, and can leave blank the optional parameter. To know exactly what is required and what is not, using Help button in section 2, you can find this information.

dialog-6-required-params.png

The image about is the description of the function __RandomString, you see “Length” and “Characters to use” are the required parameters. So when you want to use it, you must input the corresponding value to these params.

dialog-7-required-params-2.png
I’ve inputted value for Length and Characters to use the value of __RandomString function

4. Function Syntax

After completing input all the parameters inside the Function Parameters table, now it’s time to generate the function for using. It’s very easy, just click the button “Generate & Copy to clipboard”. You will see the syntax for your function with full information from the parameters which you inputted before. The next step is to paste that function into the place which you want to use.

2018-10-11_09-46-59.gif

Look at the example gif above, ${__RandomString(5,abcdef,)} and ${__RandomString(10,xyzt,)} are the syntax for the __RandomString function base on my inputted values.

5. The result of the function is

This feature has been released from version 4.0, as the description of this field’s label, right after clicking the “Generate & Copy to clipboard” button, it helps to show the result of the function (with your parameters’ value) if any.

For example, I will continue with the __RandomString, let’s see how it work.

2018-10-11_10-37-13.gif

With the help of the result field, you can test to see if the function works as your expectation, you can have exactly function and save much time.

In some cases, if the parameters are not correct, missing the required field, or wrong data type of the value, etc. all exceptions are also shown into the result field. Look into the example below.

2018-10-11_10-46-16.gif

I tried to enter a wrong value of the length and the characters for that function, and when trying to generate the function syntax, the result field shows us the error. It’s good, right?

6. Current JMeter Variables

This field has just been released in version 5.0, in my opinion, this feature is also good. This helps to show all variables which are created from the functions so you can re-use those variable as a value of the parameter for other functions.

The example below will show you how this field works.

2018-10-11_11-08-52.gif

In this example, I did some steps:

1. I create function __Random with will return a random number between 1 and 10, then store the result after random into the variable called MY_NUMBER, you see, it returns 8 in this case.
2. Next, I want to use another function, it’s __RandomString, and I want to reuse the value which the __Random function return above, so I will call the variable MY_NUMBER as the value of the “Random string length” field.
3. Click “Generate & Copy to clipboard”, you see the result is normal, with the random value is hefdffeb, it’s exact 8 characters. Don’t believe? You can check it yourself.

7. Reset Variables

Yes, I know you all will know what this button is, after clicking on it. It’s related to the Current JMeter Variables field, after using, re-using the variables for your function, now you want to clear them all, no need to store those variables anymore, reset it to the original. Just click Reset Variables, as you wish, all are reset.

2018-10-11_11-19-02.gif


With the help of the Function Helper, I hope you all (especially the new JMeter) can use the JMeter function in proficiently way, exactly and no more barrier. Still having some questions? No worry, just leave your comment below this post, I will help to support you all. Thank you for reading!

Advertisements