• How to implement If condition

    From Swetha Gorantla@21:1/5 to All on Wed Aug 25 04:01:54 2021
    Can someone please help me to resolve this issue?
    I have the following code

    async function reserved_slot(page, target_url) {
    var fifthwkslotdate= new Date();
    fifthwkslotdate.setDate(fifthwkslotdate.getDate() + 7);
    await page.goto(`${target_url}en-GB/slots/delivery/${fifthwkslotdate}?slotGroup=1`, {waitUntil: 'networkidle2'});
    await page.waitForTimeout(3000);
    await page.screenshot({path: 'HomeDeliveryFifthwkPage.png'});
    await page.click('[class="button button-secondary small available-slot--button available-slot--button--cc-link-enabled"]');
    await page.waitForTimeout(3000);
    await page.screenshot({ path: 'Reservedelslotpage.png'});

    By using this code i am reserving the slot. But if slot is not avialable in the page i have to go to another page to book the slot.
    1) await page.goto(`${target_url}en-GB/slots/delivery/${fifthwkslotdate}?slotGroup=1`, {waitUntil: 'networkidle2'}); after going to this page i can come to know whether slot is there or not by seeing this message "Delivery slots for these dates are fully
    booked". How to capture this value from the above page response.
    2) If slot is available i can book the slot using "await page.click('[class="button button-secondary small available-slot--button available-slot--button--cc-link-enabled"]');" other wise i have to go other page by using "fifthwkslotdate.setDate(
    fifthwkslotdate.getDate() + 0);". How to implement this condition.

    Thanks in advance.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)