Skip to content

Create a best practice series for k6 browser #2031

@ankur22

Description

@ankur22

What

We want to make writing k6 browser scripts simpler by creating a series of opinionated best practice docs on how best to work with k6 browser.

Why

Users currently feel that they are left in the dark in terms of best practices. It's generally up to them to read the docs and examples and the to build from there. The issue is that users are likely to be facing the same issues over and over again.

How

We should cover:

  1. Why we should use page.close:
    1. Helps with flushing of metrics;
    2. cleans up things under-the-hood, especially when working with event based APIs like page.on.
  2. Waiting for specific elements before continuing the test script after a navigation or some sort of interactions which changes the DOM.
  3. How to work with iframes.
  4. When to work with the different wait* APIs.
  5. How to work with the browser's (Chromium) performance API.
  6. How to work with the locator API:
    1. Why they are great; run through the steps a locator API goes through first before performing the requested action.
    2. E.g. Why page.locator() will never fail until the locator object is actually used.
    3. Working with all and nth instead of $$.
    4. Why working with force could be a smell.7. How to deal with cookie banners.
    5. Sometimes a page needs to be interacted with before the cookie banner appears, and other elements on the page do not work until the cookie banner has been dismissed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions