daydos/us-visa-appointment

ASC APPOINTMENT

Opened this issue · 5 comments

The program does not select the data from the ASC APPOINTMENT section (appointment date and appointment time) so when you press the reschedule button it does not take the appointment and the browser closes.
HELP ME PLEASE!
@daydos

have you solved this problem?

have you solved this problem?

No, I'm creating a new code.

hey! I added the remaining code for the ASC appointment, do you still need it?

hey! I added the remaining code for the ASC appointment, do you still need it?

yes

I'm not creating a pr as I'm not sure of which countries needed the ASC so here you go, remember to replace your ASC ID, you can retrieve it in the same way as the consularId with inspect page and getting the value of the field, let me know if you have any doubts:

`// ASC CONFIG

  // Select the specified ASC location from the dropdown
  {
    const targetPage = page;
    const element = await waitForSelectors([["#appointments_asc_appointment_facility_id"]], targetPage, { timeout, visible: true });
    await scrollIntoViewIfNeeded(element, timeout);
    await page.select("#appointments_asc_appointment_facility_id","REPLACE_YOUR_ASCID");
    await sleep(1000);
  }

  // Click on date input for ASC appointment
  {
    const targetPage = page;
    const element = await waitForSelectors([["#appointments_asc_appointment_date"]], targetPage, { timeout, visible: true });
    await scrollIntoViewIfNeeded(element, timeout);
    await element.click({ offset: { x: 394.5, y: 17.53125} });
    await sleep(1000);
  } 

  // Keep clicking next button until we find the first available date and click to that date
  {
    const targetPage = page;
    while (true) {
      try {
        const element = await waitForSelectors([["aria/25[role=\"link\"]"],["#ui-datepicker-div > div.ui-datepicker-group.ui-datepicker-group > table > tbody > tr > td.undefined > a"]], targetPage, { timeout:smallTimeout, visible: true });
        await scrollIntoViewIfNeeded(element, timeout);
        await page.click('#ui-datepicker-div > div.ui-datepicker-group.ui-datepicker-group > table > tbody > tr > td.undefined > a');
        await sleep(500);
        break;
      } catch (err) {
        {
            const targetPage = page;
            const element = await waitForSelectors([["aria/Next","aria/[role=\"generic\"]"],["#ui-datepicker-div > div.ui-datepicker-group.ui-datepicker-group-last > div > a > span"]], targetPage, { timeout, visible: true });
            await scrollIntoViewIfNeeded(element, timeout);
            await element.click({ offset: { x: 4, y: 9.03125} });
        }
      }
    }
}

  // Select the first available Time from the time dropdown for ASC appointment
  {
    const targetPage = page;
    const element = await waitForSelectors([["#appointments_asc_appointment_time"]], targetPage, { timeout, visible: true });
    await scrollIntoViewIfNeeded(element, timeout);
    await page.evaluate(() => {
        const timeOptions = document.querySelector('#appointments_asc_appointment_time').options;
        if (timeOptions.length > 1) {
            timeOptions[1].selected = true; // Select the first available time
            const event = new Event('change', {bubbles: true});
            document.querySelector('#appointments_asc_appointment_time').dispatchEvent(event);
        }
    })
    await sleep(1000);
  }

//PASTE IT JUST BEFORE OF:
// Click on reschedule button
...`