Menu
Open source

Version 1.1.0 release notes

k6 v1.1.0 is here 🎉! This release includes:

  • New count, nth, first, and last methods for the browser module’s Locator API #4797, #4825
  • The k6/experimental/webcrypto module has been removed as its functionality is available globally.
  • Group results in the full end-of-test summary are now sorted as in code and properly indented.

Breaking changes

As per our stability guarantees, breaking changes across minor releases are allowed only for experimental features.

Breaking changes for experimental modules

Remove experimental k6/experimental/webcrypto module #4851

The WebCrypto API has been available globally since v1.0.0-rc1 (or v0.58.0), and now the experimental import (k6/experimental/webcrypto) is no longer available.

The required change for users is to remove the import; the rest of the code should work.

New features

New count method for the browser module’s Locator API #4797

The new locator.Count method returns the number of elements matching the locator. Unlike other Locator API methods, locator.Count returns the result immediately and doesn’t wait for the elements to be visible.

JavaScript
import { expect } from "https://jslib.k6.io/k6-testing/0.4.0/index.js";
import { browser } from 'k6/browser'

export const options = {
  scenarios: {
    ui: {
      executor: 'shared-iterations',
      options: {
        browser: {
          type: 'chromium',
        },
      },
    },
  },
}

export default async function () {
  const page = await browser.newPage()
  await page.goto('https://quickpizza.grafana.com/login')

  expect(await page.locator('input').count()).toEqual(3);

  await page.close();
}

New nth, first and last methods for the browser module’s Locator API #4825

The new Locator API methods, nth, first, and last, can select a single element from multiple elements matched by a locator. For example, selecting a single item from a catalogue of items on an e-commerce website. Because items in this catalogue generally change often and selecting an exact element may fail in future test runs, the new methods help to prevent flaky tests, leading to more reliable tests.

JavaScript
import { expect } from "https://jslib.k6.io/k6-testing/0.4.0/index.js";
import { browser } from 'k6/browser'

export const options = {
  scenarios: {
    ui: {
      executor: 'shared-iterations',
      options: {
        browser: {
          type: 'chromium',
        },
      },
    },
  },
}

export default async function () {
  const page = await browser.newPage()
  await page.goto('https://quickpizza.grafana.com')

  await expect(await page.locator('p').first()).toContainText('QuickPizza');
  await expect(await page.locator('p').nth(4)).toContainText('QuickPizza Labs.');
  await expect(await page.locator('p').last()).toContainText('Contribute to QuickPizza');

  await page.close();
}

For a full list of changes, including UX improvements and bug fixes, refer to full release notes.