I have an element 'input[name=startdate]' with an attribute 'value="2018-06-20"' instead of using puppeteer to interact with the calendar that is used to change the date, is there anyway I can use puppeteer to set the value instead?
something like...
let newDate = '2018-01-01'
value.innerHTML = newDate
I was able to figure it out and I'm posting it here in case anyone else has the same problem.
await page.$eval('input[name=startdate]', e => e.setAttribute("value", "2018-01-01"))
If you want to set the date as a variable...
const randomDate = '2018-01-01'
await page.$eval('input[name=startdate]', (e, randomDate) => {
e.setAttribute("value", randomDate),
randomDate
)}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With