selenium – How to measure test execution duration with NewRelic Syntethics Scripts?

I’m using the newrelic synthetics scripted browser to check some user transaction flows for reliability and performance.

However the tracked duration is only about 8-10s which matches initial page load time, but not the async lazy loading of a large dataset (which is approx. 40s).

  • How can I make new relic synthetics scripted browser tests to show actual test execution duration and not only the duration of inital request?
  • How can I track actual synthetics scripted browser test execution time and plot on a diagram with new relic?

The following I already tried and seems not to fix the issue:

Using a custom insight

See new relic docs for custom insights.

In script use:

var timeStart =;
var timeEnd =;
$util.insights.set('testDuration', (timeEnd - timeStart) );

with NRQL:

FROM SyntheticCheck SELECT numeric(custom.testDurration) WHERE numeric(custom.testDurration) > 0 SINCE 1 day ago

However in newrelic browser this data is shown as strings and thus cannot be plot on a chart as measurement.

  • What do I need to do to be able to make this a numeric measurement to be drawable as chart?

Timetracking with $har

New relic docs recommend using $har

const testTimer = $har.addResource('Test Timer');
await sleep(100);

However $har is resulting in error: Check failed with reference error. $har is not defined;

  • How do I use $har correctly?

** Checking KeySet, the custom properties show us stings**

As proposed on new relic forum I checked the field type and it appears to be registered as string

NRQL FROM SyntheticCheck SELECT keyset() returns

    "results": [
        "stringKeys": [

Any other ideas how to achieve this?

Thx in advance, I really appreciate your expertise!

Read more here: Source link