Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ASC APPOINTMENT #11

Open
sajca23 opened this issue Aug 3, 2023 · 5 comments
Open

ASC APPOINTMENT #11

sajca23 opened this issue Aug 3, 2023 · 5 comments

Comments

@sajca23
Copy link

sajca23 commented Aug 3, 2023

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

@keets2012
Copy link

have you solved this problem?

@sajca23
Copy link
Author

sajca23 commented Sep 5, 2023

have you solved this problem?

No, I'm creating a new code.

@Danilo-GB
Copy link

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

@sajca23
Copy link
Author

sajca23 commented Nov 21, 2023

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

yes

@Danilo-GB
Copy link

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
...`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants