Rayrun
← Back to Discord Forum

Ensure multiple elements with same ID exists

Hey,guys. How to work around the strict mode of playwright regarding amount of selectors? For example I need to check that all checkboxes are checked with page.locator('[id ^= "board_item"]').locator('input[type="checkbox"]') ? Should I count the amount of them and then add nth to each element or what? Thank you for answers

This thread is trying to answer question "How to work around the strict mode of playwright regarding amount of selectors to check that all checkboxes are checked?"

3 replies

loop with nth and assert

or it is a specific selector for checked checkboxes then you could just assert count

@skorp32 thank you, created this loop and it works

for (let i = 0; i < checkboxes.length; i++) { const checkbox = checkboxes[i]; await expect(checkbox.nth(i)).toBeChecked(); } ,

just wanted to know maybe there is some option like in cypress with multiple:true

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 luc@ray.run.