Tracing
DevRaven supports capturing network requests and console log messages while executing browser based checks. This is especially useful to get visibility into any failing network requests or any unknown errors while executing your tests.
A warning indicator will be shown if we identified any error messages in console logs or any failed network calls while executing your test.
Network requests:
Console log messages:
Enabling Tracing
Following is the process for enabling tracing for your browser-based tests.
No-code Editor
If your test is created using no-code editor, just set Tracing to Yes or Yes (Set Trace ID) for your test and save changes. We will automatically capture all network activity and console log messages while your test is being executed.
Setting Tracing to Yes (Set Trace ID) will enable distributed tracing for your browser test. See Distributed Tracing section for more details
Scripted Editor
If you have a scripted browser test, you must update your script to start and stop tracing using the following methods.
devraven.startTracing(browserContext) - Pass the browserContext object to start tracing. This will register required listeners to capture the trace data.
devraven.stopTracing() - Invoking this method saves the captured data for processing. We recommend invoking this in finally block so any collected data is saved even if there is an assertion failure.
Following is an example snippet.
const { chromium } = require('playwright');
const { expect } = require('chai');
try {
const browser = await chromium.launch({headless:true});
const context = await browser.newContext();
devraven.startTracing(context, { distributedTraceEnabled: true }); //starts tracing with ditributed tracing
//Refer https://docs.devraven.io/docs/synthetic-monitoring/available-apis#starttracingbrowsercontext for additional to filter urls or strip query params.
const page = await context.newPage();
await page.goto(`https://www.devraven.io`, {waitUntil:'load'});
//add any other code here
await context.close();
await browser.close();
} finally {
devraven.stopTracing(); //saves the collected trace data
}