Bird
0
0

How can you extend the Base Page pattern to support multiple browsers without changing existing page classes?

hard📝 Application Q9 of 15
Selenium Java - Page Object Model
How can you extend the Base Page pattern to support multiple browsers without changing existing page classes?
AUse WebDriver interface and pass driver instance to Base Page constructor
BCreate separate Base Page classes for each browser
CHardcode browser type inside Base Page methods
DUse static WebDriver instance shared by all tests
Step-by-Step Solution
Solution:
  1. Step 1: Understand WebDriver abstraction

    WebDriver is an interface implemented by different browser drivers.
  2. Step 2: Use dependency injection for flexibility

    Passing WebDriver instance to Base Page constructor allows any browser driver to be used without code changes.
  3. Final Answer:

    Use WebDriver interface and pass driver instance to Base Page constructor -> Option A
  4. Quick Check:

    Inject WebDriver for browser flexibility [OK]
Quick Trick: Inject WebDriver instance for browser support [OK]
Common Mistakes:
  • Creating multiple Base Page classes duplicates code
  • Hardcoding browser reduces flexibility
  • Using static driver causes test interference

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Selenium Java Quizzes