Run your own JavaScript in a smartphone test

Run your own JavaScript in a smartphone test when no built-in step does what you need.

Use it to handle a flow no built-in step covers, compute a value, or send a custom metric to Analytics. The script runs on the test's device, in the same session as the other steps.

Parameters

ParameterRequiredDescription
Step titleNoThe name shown for this step in the builder and in results.
ScriptYesJavaScript code, edited in a dedicated modal.
Ignore error on this stepNoThe run continues with the next step if the script throws. Default: off.

To drive the app from the script, use the browser object: it gives you the full WebdriverIO API (a JavaScript library for automating devices and browsers). The test helpers cover the rest, for example:

// Push a custom metric to Analytics
test.metrics.create("checkout", { basket_total: 39.98 }, { currency: "EUR" });

Results and metrics

  • Timing: start, end, and duration (in seconds) recorded in the step result.
  • Status: failed if the script throws, success otherwise.
  • Output: anything the script logs is available in the step's output for debugging.
  • Custom metrics: metrics created with test.metrics.create(measurement, fields, tags) flow to Analytics like any built-in metric.

What's next?

Set variable

Store a value without writing code

Analytics

Where custom metrics show up

Last updated on