Generate TOTP codes for testing two-factor authentication flows. The step creates valid 6-digit codes that refresh every 30 seconds, automatically waits if a code is about to expire, and stores the result in a variable for use in subsequent steps like Fill.
Add the Get TOTP Code step after actions that trigger 2FA (like clicking “Log In”). The form has two fields:
Secret Token: Enter {{env.TOTP_SECRET}} or paste a token directly (not recommended for security)
Variable: Auto-generated name like supatest_totp_0 that stores the 6-digit code
The step automatically handles timing. If fewer than 15 seconds remain in the current 30-second window, it waits for a fresh code so subsequent steps have enough time to use it.
The easiest way to get the TOTP code expression is to use the Inbox in the Editor Console. This eliminates the need to manually type variable names.Workflow:
Run your test until the Get TOTP Code step - Use “Run From Step” or run the test partially until the Get TOTP Code step completes
Open the Inbox tab in the Editor Console (bottom panel)
Click on the TOTP entry to view its details
Copy the expression using the curly braces icon {...} next to the code
Paste the expression directly into your next step (Fill, API Request, etc.)
The Inbox provides two copy options:
Copy icon - Copies the actual code value (e.g., 123456)
Curly braces icon {...} - Copies the expression (e.g., {{vars["supatest_totp_0"]}})
This approach ensures you always use the correct variable name without manual typing.
Step 4: Add a Get TOTP Code step with Secret Token: {{env.TOTP_SECRET}}Step 5: Get the expression from the Inbox
Run the test until Step 4 completes
Open the Inbox tab in the Editor Console
Click on the TOTP entry
Click the curly braces icon {...} to copy the expression
Add a Fill step for the 2FA code field and paste the expression
Step 6: Add a Click step for the Verify buttonThe generated code is valid for at least 15 seconds after Step 4 completes, giving Steps 5 and 6 time to run.