Rayrun
← Back to Discord Forum

How to group all elements with the same id in array

I have multiple elements in the page with data-testid .

I want to group them into an array and iterate them in order to do an assertion. so in each iteration i should have Locator to do the assetion on

I didn't find something in playwright docs for this...

This thread is trying to answer question "How can I group elements with the same 'data-testid' into an array for iteration and assertion in Playwright?"

2 replies

I found a solution in the docs after all, using the method all() on Locator https://playwright.dev/docs/api/class-locator#locator-all

Related Discord Threads

TwitterGitHubLinkedIn
AboutQuestionsDiscord ForumBrowser ExtensionTagsQA Jobs

Rayrun is a community for QA engineers. I am constantly looking for new ways to add value to people learning Playwright and other browser automation frameworks. If you have feedback, email [email protected].