Skip to content

Waiting for elements after DOM changes #2081

@ankur22

Description

@ankur22

What

Test scripts may fail or interact with stale elements after navigation or interactions that modify the DOM. Just waiting for the page to finish navigation isn't enough since modern websites perform async operations which could change the DOM after the navigation occurs.

Think about grafana.com. When the user logs into their account, sometimes they need to wait for their instance to spin up, so they should wait for the landing page rather than try to work with the navigation since they'll likely be hitting the loading page otherwise.

Solution

Wait for specific elements to be available before continuing the test script. Use k6's locator APIs such as wait or page.waitForSelector.

This is critical when dealing with SPAs or dynamic content.

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