I would like to crawl flight data from the following page: /
I managed to select the airports, but this page has a Datepicker and I don't get it how to use it programmatically. With a Click on the Startdate Input i can open the Datepicker,
await page.click('#txt_FromDateText');
But what do I need to do to select the date/date range ? I tried to wait for a day selector and click One, but this does not work.
const daySelector = '.available.flight-present';
await page.waitForSelector(daySelector);
const elements = await page.$('.available');
const el = Array.from(elements).filter(el => {
return el.dataset.usrDate === '2019-10-26';
})[0];
console.log(el);
await el.click();
console.log ist printing the element, but it does not get selected in the datepicker. What am I doing wrong?
Thanks for any hints.
I would like to crawl flight data from the following page: https://www.airprishtina./de/
I managed to select the airports, but this page has a Datepicker and I don't get it how to use it programmatically. With a Click on the Startdate Input i can open the Datepicker,
await page.click('#txt_FromDateText');
But what do I need to do to select the date/date range ? I tried to wait for a day selector and click One, but this does not work.
const daySelector = '.available.flight-present';
await page.waitForSelector(daySelector);
const elements = await page.$('.available');
const el = Array.from(elements).filter(el => {
return el.dataset.usrDate === '2019-10-26';
})[0];
console.log(el);
await el.click();
console.log ist printing the element, but it does not get selected in the datepicker. What am I doing wrong?
Thanks for any hints.
Share Improve this question asked Oct 22, 2019 at 15:25 Simon HansenSimon Hansen 6909 silver badges18 bronze badges3 Answers
Reset to default 7the solution is to remove the readonly attribute from the #txt_FromDateText element.
await page.focus('#txt_FromDateText');
await page.$eval('#txt_FromDateText',(e) => e.removeAttribute("readonly"));
Then you can enter any date with "await page.type".
:)
select your date
await page.focus('#txt_FromDateText');
if your date is in some other format just change it accordingly.
await page.keyboard.type('20191026');
If you want to select a particular date, you can do it as below:
await page.$eval('#txt_FromDateText', el => el.value = '2021-03-02');