Bird
0
0

You want to scroll to a hidden button inside a scrollable div with id "menu". Which approach correctly scrolls the button into view using Selenium Java?

hard📝 Application Q8 of 15
Selenium Java - JavaScriptExecutor
You want to scroll to a hidden button inside a scrollable div with id "menu". Which approach correctly scrolls the button into view using Selenium Java?
AUse Actions class to send PAGE_DOWN key until button is visible
BLocate the button element and use JavascriptExecutor to call scrollIntoView on it
CUse driver.navigate().refresh() to reload and reveal the button
DCall driver.findElement(By.id("menu")).click() directly
Step-by-Step Solution
Solution:
  1. Step 1: Identify correct scrolling method

    scrollIntoView on the button element ensures it becomes visible inside the scrollable div.
  2. Step 2: Evaluate other options

    Refreshing or clicking menu won't scroll button; sending PAGE_DOWN may be unreliable.
  3. Final Answer:

    Locate the button element and use JavascriptExecutor to call scrollIntoView on it -> Option B
  4. Quick Check:

    scrollIntoView on element inside scrollable div [OK]
Quick Trick: Scroll hidden element directly with scrollIntoView [OK]
Common Mistakes:
  • Refreshing page expecting scroll
  • Clicking parent div instead of scrolling
  • Using keyboard keys without checking visibility

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Selenium Java Quizzes