Practice tasks
A booking journey has more state than a shopping journey: the doctor, the date and the slot all have to survive from one page to the next. That is what makes it worth automating.
1. Find a doctor
- Search for
cardioand assert every card shows Cardiology. - Pick a speciality from the dropdown and assert the count text matches the number of cards.
- Tick two branches and assert only those branches appear.
- Drag the fee slider to 600 and assert no card shows a higher fee.
- Choose 15 years and above and assert every card meets it.
- Clear the filters and assert all 14 doctors are back.
- Sort by fee ascending and assert the order; sort by rating and assert the first card is the highest.
2. Slots
- Open a doctor and assert the profile matches the card you clicked.
- Assert seven date buttons are shown and the first one is selected.
- Assert Book this slot is disabled before a slot is picked.
- Click a booked (disabled) slot and assert nothing is selected.
- Pick a free slot, assert the confirmation text, then change the date and assert the selection resets.
- Assert the morning and evening groups contain the right times.
3. Booking form
- Submit the empty form and assert every required field is listed.
- Enter an age of 0 and of 130 and assert both are rejected.
- Enter a 9-digit mobile number and assert the message.
- Tick I will use health insurance and assert the insurer fields appear and become required.
- Enter a 4-character reason and assert the minimum-length message.
- Leave the consent box unticked and assert the appointment is not booked.
- Book a valid appointment and assert the ID matches
MC-XXXXXX.
4. Appointments and reports
- Assert the new appointment appears under My appointments as Upcoming.
- Cancel it and assert the status changes and the cancel button disappears.
- Filter by Cancelled and assert only that one is shown.
- On Lab reports, search for a report ID and assert exactly one row.
- Filter by type and by status together and assert the row count text.
- Sort by date and assert the order; click again and assert it reverses.
- Click Download on a ready report and assert the file is saved; assert the button is disabled while a report is in progress.
Where the data lives
Appointments and the slot you picked are kept in localStorage under mc_appointments
and mc_booking. Reset the app between runs with:
// Selenium
((JavascriptExecutor) driver).executeScript("window.localStorage.clear()");
// Playwright
await page.evaluate(() => localStorage.clear());