Run your own JavaScript in a smartphone test
Run your own JavaScript in a smartphone test when no built-in step fits: an uncovered flow, a computed value, a custom metric sent to Analytics.
Run your own JavaScript inside the test: handle a flow no built-in step covers, compute a value, or push a custom metric to Analytics. The script runs in the test's device session with the full WebdriverIO API available.
Parameters
| Parameter | Required | Description |
|---|---|---|
| Step title | No | The name shown for this step in the builder and in results. |
| Script | Yes | JavaScript code, edited in a dedicated modal. |
| Ignore error on this step | No | The run continues with the next step if the script throws. Default: off. |
Inside the script you can use the WebdriverIO browser object to drive the session, and the test helpers, 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?
Last updated on