Selenium WebDriver 4

Handle infinite scroll

Hard120 pts~45 min
  • Infinite scroll
  • Loops
  • Explicit waits
Practice app · Gear Shop

A product grid loaded from a real API with search, filters, infinite scroll and a checkout that calls a payments API.

Test URL
/lab/selenium-handle-infinite-scroll

Your starter code already declares TEST_URL — never hardcode a host.

Objective

Scroll the grid until no more products load, then verify the complete catalogue without duplicates.

Your task

  1. 1Record the current number of .product-tile elements.
  2. 2Loop: scroll to the bottom (window.scrollTo(0, document.body.scrollHeight)) and wait until the count grows or #scroll-sentinel reports the end.
  3. 3Stop when the count no longer grows.
  4. 4Assert 12 unique data-id values and #scroll-sentinel reads “You’ve seen all 12 products”.

Acceptance criteria

  • Scrolling runs in a loop with a clear exit condition
  • 12 tiles are loaded
  • #scroll-sentinel shows the end message
  • At least 2 assertions pass

Constraints

  • Do not click #load-more.
  • Do not use fixed sleeps — synchronise with explicit waits.

Selenium WebDriver 4 · Selenium · Tables & dynamic content