i learn how to use puppeteer and i try to click on checkbox with the same Content.
here is my code + picture screen shot please help me how to solve that ? thank you alot.
I do not want to remove the (?.checked) because if I do not do it then it inserts V and then remove the V ... I want him to mark YES twice but also check if he has already marked 1 so that he does not lower the V he has already marked! Congratulations and many thanks to anyone who will help me understand how to do it please
here is the code:
for (let j=0; j<textforgroups.msg.myAnswertext.length; j++)
{
checkbtn.arr[j] = await page.evaluate(({textforgroups,j}) =>
{
return Array.from(document.querySelectorAll('label')).find(el => el.textContent.includes(textforgroups.msg.myAnswertext[j]))?.textContent;
},{textforgroups,j})
if(checkbtn.arr[j])
{
await page.evaluate(({checkbtn,j}) =>
{
checkbtn.checkboxselcted =[...document.querySelectorAll("input[type='checkbox']")].find(element => element.labels[0].textContent.includes(checkbtn.arr[j]))?.checked
if(checkbtn.checkboxselcted===true) //if is checked its mean its give V in the checkbox.
console.log("Checkbox Selected!");
else
[...document.querySelectorAll('label')].find(element => element.textContent.includes(checkbtn.arr[j]))?.click();
},{checkbtn,j})
}
}
Aucun commentaire:
Enregistrer un commentaire