Skip to content

[Feature] .locator should also take in Locator type #19642

Closed

Description

@gselsidi

so chaining elements such as .byRole, .filter, .locator
.locator should take in an actual Locator as to work better with page object model as opposed to just string

it comes in handy when chaining to find elements in a table, or in dropdown that might have icons next to each name, and that icon you've set as an Locator in your POM file.

await dashboardPage.columnHeaders .filter({ hasText: "Name/UID" }) .locator(dashboardPage.downArrowTableSortIcon);

Activity

  1. dgozman commented on Mar 23, 2023

    @dgozman
    Collaborator

    Chaining locators is now possible with Locator.locator() method. Check out this guide.

  2. gselsidi commented on Mar 23, 2023

    @gselsidi
    Author

    Dmitry Gozman (@dgozman) thanks for this! I looked at the guide didn’t see any examples or is it not updated yet?

    If so can you provide an example.

  3. dgozman commented on Mar 23, 2023

    @dgozman
    Collaborator

    The second snippet in the guide has an example of locator chaining:

    const saveButton = page.getByRole('button', { name: 'Save' });
    // ...
    const dialog = page.getByTestId('settings-dialog');
    await dialog.locator(saveButton).click();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions