I have used the code like this:
await page.$$eval( 'input[name=name_check]', checks => checks.forEach(c => c.checked = true)
But this is for multiple checkboxes. I want to use this for a single checkbox.
How can I check only one checkbox?
I have used the code like this:
await page.$$eval( 'input[name=name_check]', checks => checks.forEach(c => c.checked = true)
But this is for multiple checkboxes. I want to use this for a single checkbox.
How can I check only one checkbox?
You can use page.$eval() instead of page.$$eval() to check one checkbox instead of multiple checkboxes:
await page.$eval('input[name="name_check"]', check => check.checked = true);