---
title: "Run your own JavaScript in a web test"
sidebarTitle: "Custom step"
description: "Run your own JavaScript in a web test when no built-in step fits: an uncovered flow, a computed value, a custom metric sent to Analytics."
lastUpdated: "2026-09-23"
---

> **For AI agents:** the complete documentation index is at [llms.txt](/llms.txt). Append `.md` to any page URL for its markdown version.

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 browser 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:

```javascript
// 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?

<Columns cols={2}>
  <Card title="Set variable" icon="brackets-curly" href="/tests/actions/web/setvariable">

    Store a value without writing code

</Card>
  <Card title="Analytics" icon="chart-line" href="/analytics/dashboards">

    Where custom metrics show up

</Card>
</Columns>
