I'm using puppeteer to try and access the 'aria-label' attribute from the query below but it is returning results of type:
JSHandle@node
Which means when I try to .getAttribute('aria-label') it is undefined.
I am trying to get a list of available dates from the flatpickr calendar.
Can anyone tell me how to do this correctly?
Thanks.
(async () => {
const arias = await page.evaluate(() => {
const results = document.querySelectorAll('span.flatpickr-day:not(.prevMonthDay):not(.nextMonthDay):is(.flatpickr-disabled)');
dates = {};
if (results.length) {
for ( var i = 0; i < results.length; i++ ) {
dates.push(results[i].getAttribute('aria-label'));
}
}
return dates;
});
})