Overview
Code execution steps let you run custom JavaScript in the browser during a test. This is useful when your test needs to interact with APIs, set up data, or perform actions that aren’t possible through the standard click/type/assert steps. The code runs in the browser context viapage.evaluate(), so you have access to fetch(), document, window, and other browser APIs.
Adding During Recording (Recommended)
The easiest way to add a code step is during a Chrome extension recording. The code runs immediately so you can verify it works before saving.Start a recording
Open the Decipher Recorder sidebar and click Record Tab to begin recording your user flow.
Click Add Code Step
In the recording sidebar, click the + Add Code Step button. This appears between the action log and the “Watching…” indicator.
Write your code
Enter your JavaScript in the code editor. You can use top-level
await — the code is wrapped in an async function automatically. A template with a fetch example is pre-filled to get you started. Use return to pass a value back — it will be shown in the step results.Add a description
Describe what the code does (e.g., “Create test user via API”). This description appears in the action log and in the generated test steps.
Run & Add Step
Click Run & Add Step. The code executes immediately in the page. You’ll see whether it succeeded or failed, along with any return value. The step is added to your recording’s action log with before/after screenshots.
Adding in Edit Mode
You can also add code steps to an existing test:Example
Timeout
Each code step has a configurable timeout (default: 30 seconds, max: 300 seconds). If the code doesn’t finish within the timeout, the step fails. You can adjust the timeout when adding the step.Behavior
- Errors — If the code throws an error or times out, the step fails and the error message is shown in the test results.
- Return values — If your code returns a value, it is captured and displayed in the step results.
- Variable persistence — Variables declared with
const/letdon’t persist across steps. Usewindow.myVar = ...to share data between code steps. - Navigation — If your code navigates the page (e.g.,
window.location.href = ...), subsequent steps run on the new page.
Code execution steps are user-authored only — they cannot be generated by AI-based editing.
Need help? Contact our support team.