Skip to content

Understanding locator API #2080

@ankur22

Description

@ankur22

What

Confusion about when locators are evaluated vs created. For example:

const l = page.locator('#some-id');

is a synchronous API that hasn't interacted with the page yet. It doesn't return an error or do any form of validation at this stage, so if the selector is incorrect you will only find out later when you use a locator method like:

await l.click();

does it actually use the selector #some-id in the locator against the website under test.

Solution

Some details already exist: https://grafana.com/docs/k6/latest/javascript-api/k6-browser/locator/.

Also take a look at the Playwright docs to get a better understanding of what they do and why they're useful.

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