Hospital Portal Automation Practice (MediConnect)
A hands-on guide to testing a hospital management application with Selenium and Playwright · TesterRank team
MediConnect is a hospital management system with patient registration, doctor directory, appointment booking, medical records, lab reports, pharmacy and billing. It has separate Doctor and Admin users, so it is a natural place to practise role-based testing.
Healthcare software must be accurate and permission-aware. Practising here teaches you to verify that each role sees only what it should, and that bookings never double-allocate a time slot.
Demo login
| URL | /hospital/login |
|---|---|
doctor@mediconnect.com | |
| Password | Medi@123 |
| Key locators | [data-testid='email-input'], [data-testid='password-input'], [data-testid='login-btn'], [data-testid='login-error'] |
All data is fictional and stored only in your browser. Clear site storage to reset the app.
What makes this app challenging to automate
Role-based access
Log in as Doctor (doctor@mediconnect.com) and Admin (admin@mediconnect.com) and verify menu items and page access differ.
Appointment slots
Booking a slot should make it unavailable. Test double-booking and past dates.
Search across large lists
Doctor and patient lists support search and filters — assert on every returned row.
Billing totals
Bills combine consultation, lab and pharmacy items. Verify line items sum to the total.
Pages and what to practise on each
| Page | Practise |
|---|---|
| Patient registration | Long form with dates, radio buttons and validation. |
| Doctors | Search, department filter, cards/grid assertions. |
| Appointments | Date and slot selection, booking confirmation. |
| Medical records | Table data verification and detail views. |
| Lab reports | Status badges and report downloads. |
| Billing | Invoice line items and totals. |
Starter code: login test
Both examples use the app's stable data-testid attributes, which is the locator strategy most teams prefer over long XPaths. Copy one into your project, run it, then extend it to the pages above.
import org.openqa.selenium.*;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.support.ui.*;
import org.testng.Assert;
import org.testng.annotations.*;
import java.time.Duration;
public class MediConnectLoginTest {
WebDriver driver;
WebDriverWait wait;
@BeforeMethod
public void setUp() {
driver = new ChromeDriver();
wait = new WebDriverWait(driver, Duration.ofSeconds(10));
driver.get("https://www.testerrank.com/hospital/login");
}
@Test
public void validLoginOpensApp() {
driver.findElement(By.cssSelector("[data-testid='email-input']"))
.sendKeys("doctor@mediconnect.com");
driver.findElement(By.cssSelector("[data-testid='password-input']"))
.sendKeys("Medi@123");
driver.findElement(By.cssSelector("[data-testid='login-btn']")).click();
// Explicit wait: the URL leaves the login page after success
wait.until(ExpectedConditions.not(
ExpectedConditions.urlContains("/login")));
Assert.assertFalse(driver.getCurrentUrl().contains("/login"));
}
@AfterMethod
public void tearDown() { driver.quit(); }
}import { test, expect } from '@playwright/test';
test.describe('MediConnect login', () => {
test.beforeEach(async ({ page }) => {
await page.goto('https://www.testerrank.com/hospital/login');
});
test('valid credentials open the app', async ({ page }) => {
await page.getByTestId('email-input').fill('doctor@mediconnect.com');
await page.getByTestId('password-input').fill('Medi@123');
await page.getByTestId('login-btn').click();
await expect(page).not.toHaveURL(/login/);
});
test('wrong password shows an error', async ({ page }) => {
await page.getByTestId('email-input').fill('doctor@mediconnect.com');
await page.getByTestId('password-input').fill('Wrong@999');
await page.getByTestId('login-btn').click();
await expect(page.getByTestId('login-error')).toBeVisible();
});
});Guided exercises
- Book a Specialist Doctor Appointment (beginner)Automate doctor discovery and appointment booking flow.
- Patient Registration Form Validation (beginner)Automate new patient registration and verify mandatory field validation errors.
- Search Doctors by Specialty & OPD Timings (intermediate)Verify dynamic filtering of doctors directory across multiple departments.
- Medical Records & Lab Report Download (intermediate)Automate access to diagnostic lab reports and verify download triggers.
- Inpatient Hospital Billing & Insurance Co-Pay (advanced)Validate itemized medical bill calculation with health insurance deduction.
Edge cases worth testing
- Register a patient with a future date of birth.
- Book an appointment in the past or on an already-booked slot.
- Access an admin-only page directly by URL as a Doctor.
- Search with special characters or an empty query.
Test case writing practice
Before automating, write manual test cases. This portal has 19 reference scenarios across Doctor Appointments, Pharmacy & Billing, Patient Registration & OPD Card, Lab Test Booking & Report Download. Try the test case challenge.
Interview questions from this app
How do you test role-based access control?
Build a matrix of roles × pages/actions, then automate both positive (allowed) and negative (blocked, including direct URL access) checks for each role.
How do you handle test data for registration forms?
Generate unique data per run (e.g. Faker or timestamps) so tests never collide, and clean up or reset state afterwards.