Bird
0
0

Which of the following JavaScript commands can be used with executeScript in Selenium Java to scroll the webpage to the bottom?

easy📝 Conceptual Q3 of 15
Selenium Java - JavaScriptExecutor
Which of the following JavaScript commands can be used with executeScript in Selenium Java to scroll the webpage to the bottom?
Awindow.scrollTo(0, document.body.scrollHeight);
Bwindow.scrollBy(0, -document.body.scrollHeight);
Cdocument.scrollTop = 0;
Dwindow.scrollTo(document.body.scrollHeight, 0);
Step-by-Step Solution
Solution:
  1. Step 1: Understand scrolling commands

    window.scrollTo(x, y) scrolls to absolute position; document.body.scrollHeight is page height.
  2. Step 2: Identify correct usage

    Scrolling to bottom requires y = document.body.scrollHeight, x = 0.
  3. Final Answer:

    window.scrollTo(0, document.body.scrollHeight); -> Option A
  4. Quick Check:

    Scroll to bottom uses scrollTo with page height [OK]
Quick Trick: Use scrollTo(0, document.body.scrollHeight) to scroll down [OK]
Common Mistakes:
  • Using negative values to scroll down
  • Confusing scrollBy with scrollTo
  • Swapping x and y coordinates

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Selenium Java Quizzes