Bird
0
0

You want to extend your Page Object Model to support multiple pages with shared components. What is a good design approach?

hard📝 Application Q9 of 15
Cypress - Test Organization and Patterns
You want to extend your Page Object Model to support multiple pages with shared components. What is a good design approach?
APut all selectors and methods for all pages in one large class
BUse global variables for selectors and import them in tests
CCreate separate Page Object classes for each page and a base class for shared components
DWrite all selectors directly in test files without classes
Step-by-Step Solution
Solution:
  1. Step 1: Consider maintainability for multiple pages

    Separating Page Object classes per page keeps code organized and manageable.
  2. Step 2: Use inheritance or composition for shared components

    A base class or helper class for shared elements avoids duplication and promotes reuse.
  3. Final Answer:

    Create separate Page Object classes for each page and a base class for shared components -> Option C
  4. Quick Check:

    Separate classes + base for shared = scalable design [OK]
Quick Trick: Use base classes for shared parts, separate classes per page [OK]
Common Mistakes:
  • Putting all pages in one big class
  • Using global variables instead of classes
  • Writing selectors only in tests

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Cypress Quizzes