No video

Page locators are the better way to select elements in Playwright

Playwright offers different ways to select and access elements. Learn in this video why page locators ("page.locator") are preferred over element handles ("page.$").
Find more information in the Playwright documentation: playwright.dev/docs/locators#...
#playwright

Пікірлер: 10

  • @milakalmykova5728
    @milakalmykova5728 Жыл бұрын

    Thanks a lot it was very helpful🙏

  • @ChecklyHQ

    @ChecklyHQ

    Жыл бұрын

    Most welcome 😊

  • @taeeunchoi8138
    @taeeunchoi8138 Жыл бұрын

    awesome! Thanks a lot!

  • @ChecklyHQ

    @ChecklyHQ

    Жыл бұрын

    Happy it was useful!

  • @NikolayObraztsov
    @NikolayObraztsov Жыл бұрын

    I have a question about name of locators. If I have some locator which has different id (mn-235425 - some random numbers), how can I ignore numeric part?

  • @ChecklyHQ

    @ChecklyHQ

    Жыл бұрын

    Hello Nikolay, you could use a CSS attribute selector in your locator - `const button = page.locator("[id^=mn-]")`. But keep in mind that it's best practice to select elements based on user-facing characteristics such as text or role to test "real" user behavior. Hope this helps. 🦝

  • @gdd546
    @gdd5468 ай бұрын

    what does one dollar vs 2 dollar signs do?

  • @ChecklyHQ

    @ChecklyHQ

    8 ай бұрын

    `page.$` selects one whereas `page.$$` selects all elements in the page. That said, both methods are deprecated now and you should favor `page.locator` or the user-first locators (`page.getByRole`). Hope this helps. :)

  • @dragon3602010
    @dragon3602010 Жыл бұрын

    And what's the equivalent of $$ with the locators

  • @stefanjudis

    @stefanjudis

    Жыл бұрын

    If I'm not mistaken, `page.locator` should work with the same selectors as `page.$$`. :)

Келесі