Inside every tr I want to get the date from td:nth-child(2) and compare it with today's date. If they are equal I want to click td:nth-child(5) . I want to do the same process for several tr.
I tried to use loop but I received errors like
>Error: ... 'tbody > tr:nth-child(undefined) > td:nth-child(2)' is not a valid selector. OR >ReferenceError: i is not defined
Can anyone help me with this please?
const data = await page.evaluate(() => {
const date = document.querySelector('tbody > tr:nth-child('+i+') > td:nth-child(2)').innerText;
return date;
});
if (data === today) {
await page.click('tbody > tr:nth-child('+i+') > td:nth-child(5)');
}
})();