← Back to Discord Forum

Hello Everyone - How to handle multiple checkbox selection

Jessey Alan Paul Sposted in #help-playwright
Open in Discord
Jessey Alan Paul S

How to handle multiple checkbox selection. With index value. For the same.

await page.locator('#language-option-0-checkbox').check();
await page.locator('#language-option-1-checkbox').check();

This thread is trying to answer question "How can I handle multiple checkbox selection with index value?"

1 reply

@Jessey Alan Paul S you can try below code

// Get the total number of checkboxes const totalCheckboxes = await page.locator('input[type="checkbox"]').count();

// Iterate over the checkboxes on their index for (let i = 0; i < totalCheckboxes; i++) { const checkbox = await page.locator(#language-option-${i}-checkbox); await checkbox.check(); }

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.