Bird
0
0

How can you combine multiple @FindBy annotations to locate an element that matches either of two locators?

hard📝 Application Q9 of 15
Selenium Java - Page Object Model
How can you combine multiple @FindBy annotations to locate an element that matches either of two locators?
AUse <code>@FindBys</code> annotation with multiple <code>@FindBy</code> inside.
BUse <code>@FindAll</code> annotation with multiple <code>@FindBy</code> inside.
CUse multiple <code>@FindBy</code> annotations on the same field.
DUse <code>@FindBy</code> with comma-separated locators.
Step-by-Step Solution
Solution:
  1. Step 1: Understand @FindBys vs @FindAll

    @FindBys is used for AND condition (all locators must match). @FindAll is used for OR condition (any locator matches).
  2. Step 2: Identify correct annotation for OR condition

    To locate element matching either locator, use @FindAll with multiple @FindBy annotations inside.
  3. Final Answer:

    Use @FindAll annotation with multiple @FindBy inside. -> Option B
  4. Quick Check:

    @FindAll = OR locators, @FindBys = AND locators [OK]
Quick Trick: Use @FindAll for OR, @FindBys for AND multiple locators [OK]
Common Mistakes:
  • Confusing @FindBys and @FindAll
  • Trying multiple @FindBy on one field
  • Using comma-separated locators in @FindBy

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Selenium Java Quizzes