Skip to content

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

Automatic network requests capturing

By default, logging is automatically enabled for all network requests which use URLSession.shared, URLSessionConfiguration.default and URLSessionConfiguration.ephemeral configuration.

If you wish to enable network logging for any other/custom session configuration you can simply call:

AppeliumTests.enableLogging(for: mySessionConfiguration)

Manual request logging

In case you are not using the standard URLSession or you want to capture the requests that are not automatically captured, Appelium provides you with APIs that will allow you to manually log HTTP requests:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
let token = AppeliumTests.logRequestStart(
    url: URL(string: "www.example.com/test")!, 
    method: "GET", 
    headers: headers, 
    body: body
)
AppeliumTests.logRequestFinish(
    token: token, 
    statusCode: 201, 
    headers: responseHeaders, 
    data: responseData
)

or in case of an error:

AppeliumTests.logRequestError(token: token, error: error)