In your web application, if you have 100 pages, do you create 100 Page Objects?
In your web application, if you have 100 pages, do you create 100 Page Objects?
In a typical Page Object Model (POM) framework, you often have one Page Object per logical page, but not blindly “100 pages = 100 classes.” It depends on structure and reuse.
✅When You Would Have 100 Page Objects
If:
-
You truly have 100 distinct pages
-
Each page has unique structure and behavior
-
There’s little shared functionality
Then yes — you may end up with ~100 Page Object classes.
That’s perfectly fine. A large system should have a large, well-structured test framework.
🚫 When You Should NOT Create 100 Page Objects
You shouldn’t create a new Page Object just because:
-
The URL changes but layout is identical
-
Only the data/content changes
-
The page is just a variation of the same template
Example:
/products/2
/products/3
That’s one ProductPage class, not three.
🧠 Better Design Principles
1️⃣ Think in Components, Not Just Pages
Modern applications are component-based.
Instead of:
LoginPage
DashboardPage
SettingsPage
…
You might have:
HeaderComponent
SidebarComponent
FooterComponent
LoginFormComponent
UserTableComponent
Pages then compose components, reducing duplication.
2️⃣ Use Inheritance or Base Classes
Common functionality like:
-
Navigation
-
Waiting utilities
-
Common buttons
-
Shared layouts
Should go in a:
Each page extends it.
3️⃣ Group Similar Pages
If you have:
-
CreateUserPage
-
EditUserPage
-
ViewUserPage
You might design:
Instead of three separate objects.