Succesfully have a Synthetic Test

Hey,

I’m investigating Grafana Synthetics and created some browser checks with the Chrome Recording and k6 DevTools. The issue I’m facing is that the script succeeded four steps of the check, which is in total five, but then it fails. I tried this on the Grafana website. I can’t add attachments… Who can help me with this issue?

Thanks in advance.
Frank

Script:

// Code generated by ⛰ k6 DevTools Recorder
import { browser } from 'k6/browser';
import { check } from 'k6';
import { Runner } from "https://jslib.k6.io/k6-replay/1.0.0/index.js"

export const options = {
  scenarios: {
    browser: {
      executor: "shared-iterations",
      options: {
        browser: {
          type: "chromium",
        },
      },
    },
  },
  thresholds: Runner.thresholds,
}

export default async function() {
  const runner = new Runner({
    title: "Grafana test",
    steps: []
  }, {})

  await runner.runBeforeAllSteps()

  await runner.runStep({
    type: "setViewport",
    width: 1602,
    height: 964,
    deviceScaleFactor: 1,
    isMobile: false,
    hasTouch: false,
    isLandscape: false
  })

  await runner.runStep({
    type: "navigate",
    assertedEvents: [{
      type: "navigation",
      url: "https://grafana.com/",
      title: "Grafana: The open observability platform | Grafana Labs"
    }],
    url: "https://grafana.com/"
  })

  await runner.runStep({
    type: "click",
    target: "main",
    selectors: [
      ["aria/Products"],
      ["ul.mega-menu__primary a:nth-of-type(1)"],
      ["xpath//html/body/header/div[1]/div[1]/ul[1]/li/a[1]"],
      ["pierce/ul.mega-menu__primary a:nth-of-type(1)"]
    ],
    offsetX: 42.109375,
    offsetY: 7
  })

  await runner.runStep({
    type: "click",
    assertedEvents: [{
      type: "navigation",
      url: "https://grafana.com/products/cloud/synthetic-monitoring/",
      title: ""
    }],
    target: "main",
    selectors: [
      ["div.active div:nth-of-type(4) a:nth-of-type(2) p.copy"],
      ["xpath//html/body/header/div[1]/div[2]/div/div[1]/div/div[1]/div[4]/div/div[1]/a[2]/div/div/p[1]"],
      ["pierce/div.active div:nth-of-type(4) a:nth-of-type(2) p.copy"]
    ],
    offsetX: 34.015625,
    offsetY: 29.09375
  })

  await runner.runStep({
    type: "click",
    assertedEvents: [{
      type: "navigation",
      url: "https://grafana.com/docs/grafana-cloud/testing/synthetic-monitoring/create-checks/public-probes/?pg=synthetic-monitoring&plcmt=features",
      title: ""
    }],
    target: "main",
    selectors: [
      ["aria/more than 20 Grafana managed probe locations"],
      ["div:nth-of-type(4) div.order-2 a:nth-of-type(1)"],
      ["xpath//html/body/div[1]/div/div[4]/div/div/div[1]/div/div/div/ul/li[3]/a[1]"],
      ["pierce/div:nth-of-type(4) div.order-2 a:nth-of-type(1)"],
      ["text/more than 20 Grafana"]
    ],
    offsetX: 118,
    offsetY: 10.75
  })

  await runner.runStep({
    type: "click",
    assertedEvents: [{
      type: "navigation",
      url: "https://grafana.com/docs/grafana-cloud/testing/synthetic-monitoring/set-up/set-up-private-probes/",
      title: ""
    }],
    target: "main",
    selectors: [
      ["aria/Private probes"],
      ["p:nth-of-type(3) > a"],
      ["xpath///*[@id=\"doc-article-text\"]/p[3]/a"],
      ["pierce/p:nth-of-type(3) > a"]
    ],
    offsetX: 88.65625,
    offsetY: 9.8125
  })

  await runner.runAfterAllSteps()
}

Hi Frank,

I’ve run the script and can see the problem lies in the query parameters being added in the fourth step. If you add ?pg=synthetic-monitoring&plcmt=features to the fifth URL the test will pass.

Hope that helps!