Android UI-test network logs
When an E2E test talks directly to a backend, log the request and its terminal response so Appelium can place them on the same timeline as test actions and the final failure. This is intended for networking performed by the Android test process or a custom test helper.
The request and response are paired by the same UUID. A response logged with a different UUID becomes a separate, uncorrelated entry.
Record a successful request
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | |
duration is measured in seconds. If no useful protocol name is available, pass null.
headerFields is a List<HTTPHeaderField>, preserving header order and duplicate entries such as multiple Set-Cookie headers. Do not collapse the headers into a Map if duplicates matter to the diagnosis.
Record a failed request
For a connection or client failure, log the same response model and populate error:
try {
executeRequest()
} catch (error: IOException) {
AppeliumTests.Log.n(
response = InterceptedNetworkResponse(
requestId = requestId,
url = url,
method = "GET",
statusCode = 0,
networkProtocol = null,
headerFields = emptyList(),
body = null,
duration = elapsedSeconds,
error = error
)
)
throw error
}
This retains the request ID, duration and exception class/message in the test report. Re-throw after logging if the failure should still fail the test.
Capture only what the test needs
Structured bodies are helpful for explaining a fixture or response mismatch, but they increase report size. Use null for very large, binary or irrelevant payloads. Never manually log secrets, access tokens, payment-card data or full personal records.
Before logging, redact:
Authorization, cookies and API-key headers;- tokens or credentials in query strings;
- sensitive JSON fields in request and response bodies;
- fixture email addresses or names when a stable alias is sufficient.
For requests made by the application under test, use the application's AppeliumFeedback network instrumentation rather than duplicating app traffic from the test process.
Interpreting the timeline
Add a test console log immediately before the request:
AppeliumTests.Log.i("Creating paid order fixture", tag = "Fixtures")
Then compare the following in the failed-run view:
- the console log that explains why the request was made;
- the request body and headers;
- the response status, duration and body;
- the screen, stack trace and assertion that followed.