Synthetic load time from start until element loads

We have a login widget imbedded into a customer’s page and we would like to use Synthetics to one or both of the things below.

  1. Make a get request and look for an element on the page. Use a timeout to set an alert threshold. This is basically what my code below is trying to accomplish. (if element is not found in x seconds monitor fails, thus alerting.)
  2. Get the load times of just our widget, possibly using 2 element IDs as the start/stop endpoints and putting this data into insights via $util.insights (see: Simulating returning users of the site). I’d then like to be able to graph and alert on this piece of data.

var assert = require(‘assert’);

var cfg = {
Timeout: 3000,
Url: ‘https://login.mycompany.com
};

$browser.addHostnameToWhitelist([‘google-analytics.com’]);

var start = Date.now();

$browser.get(cfg.Url).then(function(){
$browser.isElementPresent($driver.By.id(‘ius-sign-in-submit-btn’, cfg.Timeout)).then(function(isFound){
assert.ok(isFound,“Submit Button Found”);
});
});

Hi @Peter_Chi: You could use the log function on my synthetic browser template to output the times between steps. A simple change to this function would allow you to calculate the time difference between the steps as well.

1 Like