Configuration

Every testrelic-appium option: testrelic_options keys, CLI flags, environment variables, capture toggles, and redaction.

testrelic-appium is configured through pyproject.toml, command-line flags, and environment variables. Most teams set defaults in pyproject.toml and override per-run from the CLI.

testrelic_options in pyproject.toml

Set options under [tool.pytest.ini_options] using the testrelic_options list:

pyproject.toml
[tool.pytest.ini_options]
testrelic_options = [
    "outputPath=./test-results/testrelic-timeline.json",
    "screenshotOnEvery=on-failure",
    "includeNetworkLogs=true",
]

Option reference

KeyTypeDefaultDescription
outputPathstr./test-results/testrelic-timeline.jsonWhere the JSON timeline is written.
htmlReportPathstrderivedWhere the HTML report is written (derived from outputPath when unset).
openReportboolfalseOpen the HTML report automatically after the run.
includeDeviceLogsbooltrueCapture Android logcat / iOS syslog + crashlog.
includeNetworkLogsbooltrueCapture HTTP requests/responses.
includeConsoleLogsbooltrueCapture webview/browser console output.
includeScreenshotsbooltrueCapture screenshots.
screenshotOnEveryoff | on | on-failure | on-every-stepon-failureScreenshot policy.
includeVideoRecordingboolfalseRecord device video.
includeCommandsbooltrueAccepted, but not applied in 0.2.4 — commands are always recorded.
includeAssertionsbooltrueAccepted, but not applied in 0.2.4 — assertions are always recorded.
deviceLogPollIntervalint (ms)1000Background poll interval for device logs (min 100), console logs (min 250), and network capture (min 500).
maxDeviceLogsint2000Cap on device-log entries kept per session.
maxDeviceLogMbint20Accepted, but not applied in 0.2.4 — use maxDeviceLogs.
preferBiDibooltrueTry BiDi log.entryAdded before falling back to polling.
deviceSerialstr—Android device serial (as in adb devices). Enables the adb screenrecord video fallback and the mitmproxy network fallback.
autowrapDriverbooltrueAuto-wrap drivers found in test fixtures (same as --testrelic-no-autowrap when false).
testRunIdstrgeneratedUse a fixed run ID instead of a generated one.
quietboolfalseReduce console output.
redactPatternslist[str][]Extra patterns to redact from the timeline (not settable via testrelic_options — see below).
redactHeaderslist[str][authorization, cookie, set-cookie, x-api-key]Header names masked in network capture (not settable via testrelic_options).
redactBodyFieldslist[str][password, secret, token, apiKey, api_key]Body field names masked in network capture (not settable via testrelic_options).
metadatadictnullArbitrary metadata attached to the run (set in the config file).
cloudobject—Cloud upload configuration (set in the config file).

testrelic_options values are parsed as true/false, whole numbers, or plain strings, so list and object values can't be set there. Put cloud and metadata in .testrelic/testrelic-config.json instead (see Cloud Quickstart); that file also accepts outputPath and htmlReportPath.

CLI flags

Override behavior per-run from the pytest command line:

FlagDescription
--testrelic-output PATHOverride the timeline output path.
--testrelic-disableDisable the plugin for this run.
--testrelic-quietReduce console output.
--testrelic-no-autowrapDo not auto-wrap drivers found in fixtures.

Environment variables

VariablePurpose
TESTRELIC_API_KEYAPI key for cloud uploads.
TESTRELIC_CLOUD_ENDPOINTCloud endpoint (default https://platform.testrelic.ai/api/v1).
TESTRELIC_UPLOAD_STRATEGYbatch (default, upload at the end), realtime (stream as tests finish), or both.
TESTRELIC_CLOUD_TIMEOUTUpload request timeout in milliseconds (default 30000).
TESTRELIC_RUN_TYPERun-type bucket: smoke, regression, nightly, or ci.

Screenshot and video policy

screenshotOnEvery controls when screenshots are taken:

  • off — never.
  • on — capture at the end of every test.
  • on-failure — capture when a test fails (the default).
  • on-every-step — intended to capture after every command; in 0.2.4 per-step capture isn't wired up yet, so it behaves like on.

Video is opt-in via includeVideoRecording=true. Recording uses Appium screen recording first, falling back to adb screenrecord on Android when deviceSerial is set.

Device logs and network capture

  • Device logs (includeDeviceLogs) are polled in the background every deviceLogPollInterval ms and sliced per test, capped at maxDeviceLogs entries.
  • Network capture (includeNetworkLogs) uses Chrome DevTools Protocol performance logs on Android and safariNetwork on iOS.
  • Console logs (includeConsoleLogs) prefer WebDriver BiDi log.entryAdded when preferBiDi=true, falling back to polling.

mitmproxy fallback

When CDP/safariNetwork capture is not available, an optional mitmproxy fallback can record network traffic on Android. It's used only when the network-proxy extra is installed and deviceSerial is set:

pip install "testrelic-appium[network-proxy]"

Redaction

The timeline redacts sensitive data, including Appium-specific command arguments for elementSendKeys, setValueImmediate, and replaceValue. Built-in patterns also mask AWS access keys, bearer tokens, private keys, and credentials embedded in URLs, and network capture masks the redactHeaders / redactBodyFields defaults.

In 0.2.4, redactPatterns can't be set through testrelic_options (a list value is read as a single string and rejected when pytest starts), and the config file doesn't read it either. The built-in patterns always apply.

Next steps

Was this page helpful?

On this page