Skip to main content

Available APIs

Following DevRaven APIs are available for use in your scripts during execution of Browser Tests.

Test Parameters

Test Parameters specified for a test can be accessed via the following APIs.

testParams

Allows accessing the Test Parameters associated with a test

console.log(devraven.testParams.paramName); //prints the String value for paramName or undefined if not specified

console.log(devraven.testParams); //prints all the params

State Persistence APIs

persistValue(key, value)

Persists provided value to public ephemeral storage for retrieval later in any dependent tests.

key String - Key must be at least 10 characters in length up to 36 characters. We recommend using an UUID as a key.

value String - Value must not be blank or null, String type and can be up to 2000 characters in length.

//key must be between 10-36 characters, UUID is recommended
//value must be less than 2000 characters
await devraven.persistValue('MY_UNIQUE_KEY_HERE_123', 'value to be persisted');

danger

Values persisted are purged at regular hourly intervals. Values stored are not secured and accessible publicly using the key. Do not persist credentials or any sensitive information to this storage.

retrieveValue(key)

Retrieves a previously persisted value using the provided key.

Returns null if a value is not set for the provided key.

const value = await devraven.retrieveValue('MY_UNIQUE_KEY_HERE_123')

deleteValue(key)

Deletes a previously persisted value from Storage.

//if not explictly deleted, the value will be purged after ~1 hr interval
await devraven.deleteValue('MY_UNIQUE_KEY_HERE_123')

Tracing APIs

startTracing(browserContext, config)

Starts tracing network requests and console logs for the passed browserContext object.

browserContext: Browser Context object

config: optional configuration object

  • filterUrls: predicate method that is invoked per url. Return true to filter the url from tracing
  • stripQueryParams: predicate method that is invoked per url. Return true to strip queryparams from the url
  • distributedTraceEnabled: Setting true enables distributed tracing for your test. Refer Distributed Tracing for more details.
    const browser = await chromium.launch({headless:true});
const context = await browser.newContext();
devraven.startTracing(context); //starts tracing network requests and console log. Distributed tracing is not enabled
    const browser = await chromium.launch({headless:true});
const context = await browser.newContext();
devraven.startTracing(context, {
filterUrls: url => url.indexOf('/cdn-cgi') > -1, //removes all urls that contain /cdn-cgi
stripQueryParams: url => url.indexOf('/authenticate') > -1 //removes queryParams from the urls that contain /authenticate
distributedTraceEnabled: true
});

stopTracing()

Saves the network requests and console logs captured while executing the browser-based test. We recommend executing this statement in finally block so the trace data is saved even if there is an assertion failure or an exception while executing the test.

    devraven.stopTracing(); //saves the collected trace data