The Sauce Labs Cookbook

Sauce Headless

Front End Performance Testing

Analytics

External Resources

More Info


Page tree
Skip to end of metadata
Go to start of metadata

By adding the extendedDebugging capability to your Selenium test script, you can collect the console logs and HTTP Archive files generated during testing for use in debugging and build performance evaluation.

For Chrome and Firefox Only

This feature is officially supported on the last 10 versions of Chrome browsers, 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.

See the following sections for more information:

Enabling Extended Debugging

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

Additional Settings for Using Custom Firefox Profiles with Extended Debugging

You must make these additional changes in order to use a custom Firefox profile with extended debugging:

  1. In your Firefox about:config, configure these settings:
    • devtools.chrome.enabled: true
    • devtools.debugger.prompt-connection: false
    • devtools.debugger.remote-enabled: true
       
  2. Enable Firefox debugging as a  desired capability for your test:
    • "moz:firefoxOptions": {
                "args": [
                  "-start-debugger-server",
                  "9222"
                ]
              }

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 collects security errors, warnings, and messages that are explicitly logged by the browser. You can use these logs to find out which components of your web application failed to load or ran into an error, what warnings were logged by the browser, and get more information about application performance. 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 Console Logs

You can access the JS Console logs (console.json) under the Logs tab of the Test Details page on your Dashboard, or through the REST API through the assets endpoint:

curl https://YOUR_SAUCE_USERNAME:YOUR_SAUCE_ACCESS_KEY@eds.us-west-1.saucelabs.com/:jobId/console.json

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

HTTP Archive Format (HAR) Files

HAR files collect all the network requests and responses made and received by the browser during testing. You can refer to HAR files for useful debugging information, including identifying browser requests that time out, pinpointing requests slowing down the loading process, and locating faulty API calls. 

HAR Files Viewer Required

You will need a .HAR viewer to read the files. Two common applications are:

Accessing HAR Files

You can download HAR files from the Metadata tab of the Test Details page on your Dashboard, or through the REST API through the assets endpoint:

curl -O https://YOUR_SAUCE_USERNAME:YOUR_SAUCE_ACCESS_KEY@eds.us-west-1.saucelabs.com/jobId/network.har
or
curl -u SAUCE_USERNAME:SAUCE_ACCESS_KEY -O https://eds.us-west-1.saucelabs.com/jobId/network.har

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

  • No labels