Step Properties Panel Parameters

Defining parameters through the step's properties panel (JavaScript/HTML)

Most step types include the ability to define a parameter in PARAMS field, located in the Properties panel.

There are 2 types of parameters:

  • HTML: Allows you to refer to HTML Elements in your app.
  • JS (JavaScript): Allows you do define any JS expression.

Parameter Scope

The scope of the defined parameter is within the step itself. For example, if you defined the parameter in the Add custom action step, this parameter will be available to the JS function defined in the same step.

Defining an HTML parameter in a step's Properties panel

The following procedure uses the Custom Action step as an example, but it applies to all steps that include the PARAMS field in the Properties panel.

To define an HTML parameter:

  1. In a new or existing test, add a step for which you want to define the parameter. For example, add an Add Custom Action step ('+' ⇒ Testim predefined steps ⇒ Actions ⇒ Add Custom Action) .
  2. In the Add Step dialog, enter a name for the step. For example, 'Click'.
  3. Click Create Step.
    The Function editor pane is displayed on the left and the Properties pane on the right.
18431843
  1. Click on the '+' icon next to the PARAMS field, and select HTML.
428428
  1. In the AUT, select an element for which you want to assign the parameter. For example, the Twitter icon at the bottom of the page.
18031803

A snippet of the selected element is displayed in the PARAMS section.

331331
  1. Double-click the name next to the HTML title and type a new name.
315315

At this stage the HTML parameter is defined and ready to be used.

Using the parameter in the step

The defined parameter can be used within the step itself.
For example, you can define a function that uses the parameter.
In the Function pane, type a function that uses the parameter:

twitter.click()

Run the test and see that the element is clicked.

📘

In order to use Jquery in your custom validations and actions, your site needs to have Jquery installed.

Reusing the step and assigning a different parameter

The scope of the parameter that we have defined is within the step itself, but it is possible to reuse this step to create another step of the same type (e.g. Custom Action) and then simply reassign the parameter to another element (e.g., instead of the Twitter icon, we will now assign the LinkedIn icon).

To reuse the step and assign a different parameter:

  1. In the same test, add the shared step that we have previously created from the Shared Steps menu. For example, '+'Shared stepsClick
878878

The shared step is duplicated.

955955
  1. Double-click the new step to edit it.
  2. The previous parameter still exists, but you are required to assign a new HTML element, by clicking the Assign HTML button.
351351
  1. Choose another element. For example, the LinkedIn icon at the bottom of the page.
11281128

When you will run the test both buttons will be clicked.

Adding JavaScript parameter

JavaScript parameters are commonly used for constants and variables.
We will mainly use those when we want to forward values to a group or to other reusable steps.
You can find examples for using JS params here.