Skip to end of metadata
Go to start of metadata

By adding an extendedDebugging capability to your Selenium test script, you can collect both the JavasScript console logs (JS) and HTTP Archive Format (HAR) files generated by your test to use in debugging your test and build performance.

For Chrome and Firefox Only

This feature is only available for testing on Chrome browsers versions  41 and above, and Firefox browsers versions 53 and above.

File Generation May Impact Test Performance

Because your tests will generate additional assets when you use the extendedDebugging capability, there may be an impact on test performance.

extendedDebugging Capability

To generate the JS console logs and HAR files, you need to add the extendedDebugging capability to the desired capabilities of your test:

extendedDebugging : true

Once the test completes, you can access the logs and files through the Sauce Labs web interface, or with the REST API.

JavaScript (JS) Console Logs

The JS console logs are a collection of security errors, warnings, and messages that are explicitly logged by the browser. You can use these logs to find out information like which components of your web application failed to load or ran into an error, what warnings were logged by the browser, and other application performance information. The console log information is associated with the URL where it occurred, and is composed of four types of information: Log, Info, Warning, Error. In this example, you can see how an error was generated for the URL  https://pbs.twimg.com/profile_images/477099293250052097/fMFjb8gu_400x400.jpeg  when a resource failed to load:

{
   "http://webdriver.io/api/action/click.html":[
      {
         "level":"error",
         "column":0,
         "text":"Failed to load resource: the server responded with a status of 404 (OK)",
         "source":"network",
         "networkRequestId":"1543.182",
         "url":"https://pbs.twimg.com/profile_images/477099293250052097/fMFjb8gu_400x400.jpeg",
         "timestamp":1501197041.22091,
         "line":0,
         "type":"log"
      }
   ]
}

Accessing the JS Console Logs

You can access the JS Console logs (console.json) under the Logs tab of the Test Details page in the Sauce Labs web interface, or through the REST API through the assets endpoint:

curl https://YOUR_SAUCE_USERNAME:YOUR_SAUCE_ACCESS_KEY@eds.saucelabs.com/:jobId/console.json

Authentication Required

This endpoint requires that you authenticate against it using your Sauce Labs username and access key.

The topics in The Sauce Labs REST API contain more information about accessing the API and available methods. 

HTTP Archive Format (HAR) Files

HAR files are a collection of network requests and responses the browser makes and receives during the execution of your test. These files provide information like which browser requests have timed out or never loaded. which requests are slowing down the loading process, and API calls that are having errors. 

HAR Files Viewer Required

You will need a HAR files viewer to read the files. For example:

Accessing the HAR Files

You can download the HAR files from the Metadata tab of the Test Details page in the Sauce Labs web interface, or through the REST API through the assets endpoint:

curl https://YOUR_SAUCE_USERNAME:YOUR_SAUCE_ACCESS_KEY@eds.saucelabs.com/:jobId/network.har

Authentication Required

This endpoint requires that you authenticate against it using your Sauce Labs username and access key.

The topics in The Sauce Labs REST API contain more information about accessing the API and available methods. 

  • No labels