Categories: Page Load Testing

Another Step in Automating the Pageload Recordings


In a previous article, Kimberly Sereduck told us about Updates to Warm Page Load Tests and how we are continuously working to make our tests more representative of real user behavior. Besides that, we are working on automating the process of recording the website’s page load.

The Issue

One challenge in this process is the GDPR prompts that appear in the EU territory. There are a few ways the internet sites allow visitors to set their cookie preferences, from a simple notice included in the page, to prompts that load on a layer over the website. One problem with those is that they sometimes take a while to load, especially on cold loads (first page load after the browser is open). Some of them even take a good portion of the screen, obstructing the calculation of the visual metrics. cookie prompt - before cookie prompt – before

The Fix

In order to have an objective measurement of the page load times, we had to treat them in one way or the other. The automation consists of saving the minimal cookie preferences allowed by every website. - after – after

Once the prompt is dismissed, it won’t appear on subsequent loads of the page. This is translated into cleaner and more objective measurements of the site. The way we treat those prompts can be used in the future for automating all sorts of similar scenarios.

The code that handles those prompts is pretty simple. We save the list of Xpath addresses of the elements to be clicked on and we use browsertime’s click by Xpath to interact with the page.

await commands.measure.start(testUrl);
if (input_cmds) {"Searching for cookie prompt elements...");
  let cmds = input_cmds.split(";;;");
  for (let cmdstr of cmds) {
    let [cmd, ...args] = cmdstr.split(":::");, args);
    let result = await
      `return document.evaluate("` +
        args +
        `", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;`
    if (result) {"Element found, clicking on it.");
      await run_command(cmdstr, context, commands);
    } else {
        "Element not found! The cookie prompt may have not appeared, please check the screenshots."

This is how a side-by-side comparison looks before and after:

What’s Next?

This automation was tested on desktop site only, but we plan to include the mobile sites as well. And this doesn’t stop here. Gregory Mierzwinsky is working on an automated system of logging into the websites that require authentication in our scenarios.

No comments yet

Comments are closed, but trackbacks are open.