Custom Action Step (mobile)

There may be times when you want your test to perform an action or validation that is not included in the predefined steps menu. The Custom Action (mobile) step allows you to run a script using Appium 2.0 or higher for extended capabilities and validations in your tests. The script can run multiple mobile commands in batch and can also use JavaScript parameters and Element parameters, which uses the AUT elements as parameters in the test.


Custom Action Step is currently not supported for executions on Browserstack, Saucelabs, or Custom grids.

For more information, see Appium reference:

Adding a Custom Action (mobile) Step to your Test

  1. Hover over the (arrow symbol) where you want to add the Custom Action step. The action options are displayed.
  2. Click on the “M” (Testim predefined steps). The Predefined steps menu opens.
  1. Expand the Actions menu and select the Add custom action step.



Alternatively, you can use the search box at the top of the menu to search for Add custom action.

  1. In the Name the new step field, enter a (meaningful) name for this step.
  2. If this is a shared step to be made available to reuse in this or other tests, keep the box next to Shared step selected (default), and choose a folder from the Select shared step folder list where you want this step stored. Otherwise, deselect the checkbox. For more information about shared steps, see Groups.
  3. Click Create Step. The function editor opens, and the Properties panel opens on the right-hand side.
  1. In the Properties panel, in the Description field, optionally edit the description of this step. The default description is “Run shared action” (or “Run action”).
  2. Define the parameters you will need for your step as follows:
    1. In the Properties panel, click the + PARAMS button.
    2. JS parameter: If you would like to add a JavaScript parameter, select JS from the dropdown list and type in the JavaScript parameter.
    3. Element parameter: If you would like to define an element as a parameter, select Element from the dropdown list. In the AUT window, hover your mouse on the relevant element and then click on it to select it. The selected element is shown in the Target Element box in the Properties pane. If you would like to view, replace or adjust the settings for the selected element, use the procedures described in Editing Target Element Properties.
    4. The selected element is automatically named “param” or “element” (depending on whether you chose a JS parameter or HTML element). To assign a relevant name to the parameter/element, click on the edit icon and enter the desired name.

  1. Optionally fill in the following Properties:
    1. When this step fails – Specify what to do if this step fails.
    2. When to run step – Specify conditions for when to run the step. For more information, see Conditions.
    3. Override timeout – Allows you to override the default time lapse setting which causes Testim to register a fail for a test step, and specify a different time lapse value (in milliseconds).
  2. In the function text box, type in the desired JavaScript code. If you have defined parameters, you can refer to those parameters in your JavaScript code.
  3. Click the back arrow to return to the main Editor window.

The step is created.



If you opened your AUT to define an element as a parameter, click on the Toggle Breakpoint button to remove the breakpoint.

Custom Action Step Examples

changing the app during the test

The following example shows the use of the activateApp Appium command in a Custom Action step to change the app during the test. The designated app has to be installed on the target device.

Example code

return driver.activateApp("com.example.myonlineshop");

Mobile command examples: