Bird
0
0

Find the problem in this Page Object constructor:

medium📝 Debug Q7 of 15
Selenium Java - Page Object Model
Find the problem in this Page Object constructor:

public LoginPage(WebDriver driver) {
    this.driver = driver;
    PageFactory.initElements(driver, this);
}

what is missing?
ACalling super() in constructor
BDeclaration of the private WebDriver driver field
CReturning the driver from constructor
DUsing @FindBy annotations before initElements
Step-by-Step Solution
Solution:
  1. Step 1: Check class field declarations

    The constructor assigns to this.driver, so driver must be declared as a class field.
  2. Step 2: Identify missing field

    If private WebDriver driver; is missing, code will not compile.
  3. Final Answer:

    Declaration of the private WebDriver driver field -> Option B
  4. Quick Check:

    Class fields must be declared before use [OK]
Quick Trick: Declare class fields before using them in constructor [OK]
Common Mistakes:
  • Forgetting to declare driver field
  • Thinking constructor must return value
  • Confusing annotations with constructor order

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Selenium Java Quizzes