How to narrow and chain your Playwright locators

Поделиться
HTML-код
  • Опубликовано: 10 сен 2024

Комментарии • 11

  • @The4m3r
    @The4m3r 4 месяца назад

    Useful as always thank you Stefan !

  • @mncrff6687
    @mncrff6687 2 месяца назад

    This video is helpful to understand how narrowing works, so thank you for that! However, as an accessibility engineer there is one problem with the example you have used. It can be difficult for users to identify which "Remove" button is associated with which user or racoon in this case. It would be better to continue to use only the getByRole locator and add unique accessible names to each button, so when I'm navigating with a screen reader I know exactly which user's "remove" action I'm on. One way to do this without changing the visible text and/or visual design would be to add an aria-label to each button. The aria-label should contain the visible text but add more description. Ex. aria-label="Remove Ricky Racoon". With this unique accessible name you can then continue to use getByRole and know your interactive elements are uniquely named for screen reader users. Ex. getByRole('button', { name: 'Remove Ricky Racoon' })

    • @ChecklyHQ
      @ChecklyHQ  2 месяца назад

      Thank you for your detailed explanation and you're absolutely right. 💙 Great call! I didn't think of `aria-label` when looking for a narrowing example. I might record a follow up covering accessible names.

  • @roblesrt
    @roblesrt 4 месяца назад

    Thank you...very helpful! Just shared on Twitter!

    • @ChecklyHQ
      @ChecklyHQ  4 месяца назад

      Awesome, thank you!

  • @1485935
    @1485935 4 месяца назад

    Hello, I'm currently working on a project as new joiner, is there a way to use the next available port in a localhost using playwright, I'm using 5000 for example, and If this one is running I would like my test uses the next available, hope you can help me with this.

    • @ChecklyHQ
      @ChecklyHQ  2 месяца назад

      I'm not quite sure I understand, but you should be able to configure your local webserver in the Playwright config. playwright.dev/docs/test-webserver#configuring-a-web-server Does this help?

  • @HossamEldinMohamed3
    @HossamEldinMohamed3 4 месяца назад

    Love your videos 🤩 Keep it up

    • @ChecklyHQ
      @ChecklyHQ  4 месяца назад

      Thanks! 💙 Happy you like them!