Java Test Automation / Quiz
Object Design Inside the Page Layer
Review encapsulation, inheritance, composition, and polymorphism in a Java page-object design.
- Difficulty
- Medium
- Format
- Quiz
- Points
- 150
- Estimate
- 8 min
// MISSION BRIEF
Your Mission
The page layer works today but exposes locators, repeats browser mechanics, and inherits behavior it does not need. Review the class fragments as production code and choose boundaries that keep tests expressive and change local.
// FIRST CONTACT
Battle teaser
Review this page object: public class LoginPage { public By email = By.id("email"); public WebDriver driver; } Tests locate, type, and click through those public fields. Which refactor best applies encapsulation?
- AMake driver and locators private, inject the driver, and expose intent methods such as loginAs(user, password)
- BMove the public fields into each test class
- CReturn the raw driver from every page method
- DMake every field static so all tests share it
Answers, scoring, hints, and the full battle stay sealed.
// SKILL TAGS
java-ooppage-object-modelencapsulationjava-testing