Skip to main content

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
Emaildoctor@mediconnect.com
PasswordMedi@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

PagePractise
Patient registrationLong form with dates, radio buttons and validation.
DoctorsSearch, department filter, cards/grid assertions.
AppointmentsDate and slot selection, booking confirmation.
Medical recordsTable data verification and detail views.
Lab reportsStatus badges and report downloads.
BillingInvoice 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.

Selenium 4 + Java + TestNG
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(); }
}
Playwright + TypeScript
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

  1. Book a Specialist Doctor Appointment (beginner)
    Automate doctor discovery and appointment booking flow.
  2. Patient Registration Form Validation (beginner)
    Automate new patient registration and verify mandatory field validation errors.
  3. Search Doctors by Specialty & OPD Timings (intermediate)
    Verify dynamic filtering of doctors directory across multiple departments.
  4. Medical Records & Lab Report Download (intermediate)
    Automate access to diagnostic lab reports and verify download triggers.
  5. Inpatient Hospital Billing & Insurance Co-Pay (advanced)
    Validate itemized medical bill calculation with health insurance deduction.
See step-by-step instructions and expected results →

Edge cases worth testing

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.

Keep learning