Bird
0
0

In Selenium Java, what is the primary role of the @FindBy annotation in Page Object Model?

easy📝 Conceptual Q1 of 15
Selenium Java - Page Object Model
In Selenium Java, what is the primary role of the @FindBy annotation in Page Object Model?
ATo configure browser capabilities before test execution
BTo execute JavaScript code on web elements
CTo declare and initialize web elements using specific locator strategies
DTo handle browser alerts and pop-ups
Step-by-Step Solution
Solution:
  1. Step 1: Understand @FindBy usage

    The @FindBy annotation is used to locate web elements in Page Object classes.
  2. Step 2: Role in Page Object Model

    It declares and initializes WebElement fields with locator strategies like id, name, xpath, etc.
  3. Final Answer:

    To declare and initialize web elements using specific locator strategies -> Option C
  4. Quick Check:

    Annotation for element location [OK]
Quick Trick: Used to locate and initialize elements in Page Objects [OK]
Common Mistakes:
  • Confusing @FindBy with browser configuration
  • Using @FindBy to execute JavaScript
  • Assuming it handles alerts

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Selenium Java Quizzes