Network Logs

This page explains how to capture structured network logs done in UI tests. This is particularly interesting for E2E tests which interact with Backend.

AppeliumTests supports rich network log capturing from within your UI tests. This includes structured request and response information like:

  • Headers
  • Payload
  • Duration
  • Status codes
// Before starting a request generate a UUID for mapping request and response:
val requestUuid = UUID.randomUUID()

// Execute request and log it using:
AppeliumTests.Log.n(
    request = InterceptedNetworkRequest(
        requestId = requestUuid,
        url = url,
        method = method,
        headerFields = headerFields,
        body = body
    )
)

// Once the request has finished log the response:
AppeliumTests.Log.n(
    response = InterceptedNetworkResponse(
        requestId = requestUuid,
        url = url,
        method = method,
        statusCode = statusCode,
        networkProtocol = networkProtocol,
        headerFields = headerFields,
        body = body,
        duration = duration
    )
)

headerFields is a List<HTTPHeaderField>, which preserves the original order of headers and any duplicates such as multiple Set-Cookie response headers.