Bird
0
0

Which approach best follows the test class consuming page objects pattern?

hard📝 framework Q15 of 15
Selenium Java - Page Object Model
You want to write a test class that uses two page objects: HomePage and ProfilePage. You want to test the flow: login, navigate to profile, update info, and verify success message. Which approach best follows the test class consuming page objects pattern?
AWrite all element locators and actions inside the test class without page objects
BInstantiate both page objects with driver, call login on HomePage, then call updateProfile on ProfilePage, finally assert success message from ProfilePage
CCreate one page object combining HomePage and ProfilePage methods, then test all steps there
DUse driver directly in test class to click and send keys for all steps
Step-by-Step Solution
Solution:
  1. Step 1: Understand separation of concerns

    Page objects encapsulate page details; test class uses them to perform test steps and assertions.
  2. Step 2: Evaluate options for best practice

    Instantiate both page objects with driver, call login on HomePage, then call updateProfile on ProfilePage, finally assert success message from ProfilePage correctly uses separate page objects and test class calls their methods in sequence.
  3. Final Answer:

    Instantiate both page objects with driver, call login on HomePage, then call updateProfile on ProfilePage, finally assert success message from ProfilePage -> Option B
  4. Quick Check:

    Test class calls page objects methods in flow [OK]
Quick Trick: Use separate page objects, call their methods in test class [OK]
Common Mistakes:
  • Putting all locators and actions in test class
  • Combining unrelated page objects into one
  • Using driver directly instead of page objects

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Selenium Java Quizzes