Skip to content

Manage test secrets ​

Keep passwords, API keys, and one-time codes out of recorded traces, .e2e/cache/ files, and generated test code by redacting them into named secret slots at capture time and injecting SP_SECRET_<SLOT> environment variables at runtime.

Redact sensitive fields during capture ​

When inputCapture is set to "secrets-only", @softprobe/web-record and Softprobe mobile SDKs replace sensitive input values with { kind: "secret", slot } references before exporting softprobe.ui.action spans. Standard form fields keep their typed text so generated tests can replay them directly.

By default, "secrets-only" recognizes password inputs, payment-card fields, one-time-code fields, and inputs whose name, label, or identifier includes token or secret.

To redact additional fields under a specific slot name, pass secretSlots when initializing the SDK:

ts
import { RecordSdk } from "@softprobe/web-record";

RecordSdk.init({
	ingestionKey: "spk_REPLACE_WITH_INGESTION_KEY",
	serviceName: "my-web",
	captureSemanticActions: true,
	inputCapture: "secrets-only",
	secretSlots: {
		'input[name="apiKey"]': "API_KEY",
	},
});

Mobile SDKs support the same secretSlots option:

  • @softprobe/react-native. Maps testId, accessibilityId, name, or label to a slot name.
  • Android (SoftprobeUiActionRecorder). Maps view identifiers or secretSlot arguments on instrumentEditText to a slot name.
  • iOS (SoftprobeUiActionRecorder). Maps control identifiers or secretSlot arguments on recordFill to a slot name.

See JavaScript and TypeScript SDK reference for full configuration options.

Common secret slot names ​

Slot names map directly to environment variables using the SP_SECRET_<SLOT> naming convention. Use uppercase letters, digits, and underscores.

Slot nameEnvironment variableTypical input
PASSWORDSP_SECRET_PASSWORDLogin or signup password
API_KEYSP_SECRET_API_KEYAPI key or client token input
OTPSP_SECRET_OTPOne-time verification code
TOKENSP_SECRET_TOKENPersonal access token or invite token
PINSP_SECRET_PINNumeric PIN code
ADMIN_PASSWORDSP_SECRET_ADMIN_PASSWORDPrivileged or admin password

Inject SP_SECRET_<SLOT> at test runtime ​

Generated tests read secret values from the environment when they execute, so no plaintext credentials are stored in Git.

Playwright tests ​

Generated Playwright tests read process.env.SP_SECRET_<SLOT> when filling redacted fields. Export each required slot alongside your Blackbox query credentials:

bash
SOFTPROBE_TOKEN="YOUR_BLACKBOX_TOKEN" \
SOFTPROBE_WORKSPACE_ID="YOUR_WORKSPACE_ID" \
SP_SECRET_PASSWORD="YOUR_TEST_PASSWORD" \
SP_SECRET_API_KEY="YOUR_TEST_API_KEY" \
npx playwright test

Maestro flows ​

Generated Maestro YAML flows reference ${SP_SECRET_<SLOT>} in inputText steps:

yaml
- tapOn:
    id: "admin_password"
- inputText: ${SP_SECRET_ADMIN_PASSWORD}

Pass each variable with --env when running Maestro:

bash
maestro test \
	--env SP_SECRET_ADMIN_PASSWORD="YOUR_TEST_PASSWORD" \
	.maestro/

Natural-language e2e and @softprobe/e2e/mobile ​

In agent.act tests, pass secrets.get("<SLOT>") in params so @softprobe/e2e substitutes the value at runtime without writing it to .e2e/cache/. Configure the secrets map in e2e.config.ts to read process.env.SP_SECRET_<SLOT>.

Inject secrets in CI ​

Store test credentials in your CI provider's secret store and pass them as environment variables to the test job:

yaml
- name: Run Playwright UI tests
  env:
    SOFTPROBE_TOKEN: ${{ secrets.SOFTPROBE_TOKEN }}
    SOFTPROBE_WORKSPACE_ID: ${{ secrets.SOFTPROBE_WORKSPACE_ID }}
    SP_SECRET_PASSWORD: ${{ secrets.SP_SECRET_PASSWORD }}
    SP_SECRET_API_KEY: ${{ secrets.SP_SECRET_API_KEY }}
  run: npx playwright test

Legacy E2E_SECRET_<SLOT> variables ​

Older e2e.config.ts examples use a requireSecretEnv("SP_SECRET_<SLOT>", "E2E_SECRET_<SLOT>") helper that falls back to E2E_SECRET_<SLOT> when SP_SECRET_<SLOT> is unset. New generated Playwright and Maestro suites use SP_SECRET_<SLOT> directly, so prefer SP_SECRET_<SLOT> for new test suites and CI secrets.

Arex · Blackbox · UI Testing · Lisa