Task Progress0 of 2 Tasks
0%

Store Lazy Loading

An infinite-scroll catalogue that loads four products at a time as you scroll. Its length and order change on every visit. Each task ticks itself when the answer is right.

1.Tasks

Scroll to the end and countTo do

Loaded so far: 4

Goal

Scroll until “You’ve reached the end of the catalog!” appears, then type how many products are loaded.

Product number 13To do

Use the catalogue below.

Goal

Type the name of product number 13 in the catalogue.

2.Catalogue

About this Store Lazy Loading page

Lazy loading is a pattern where a page fetches and renders content only when the user scrolls near it. To automate it, scroll the list or its last item into view, then wait for the item count to grow. Playwright offers scrollIntoViewIfNeeded and mouse.wheel. Selenium uses JavaScript scrollIntoView or Actions, followed by an explicit wait.

Screenshot of the Store Lazy Loading practice page on QA Playground. Scroll to trigger dynamic content fetching.
Store Lazy Loading: Scroll to trigger dynamic content fetching.

Frequently asked questions

How do I test infinite scroll in Playwright?

Scroll the last item into view with locator.scrollIntoViewIfNeeded() or mouse.wheel(), then assert the count grows with expect(items).toHaveCount(n) or expect.poll. Repeat until the count stops changing or reaches the expected total, rather than using fixed sleeps.

How do I scroll to load more content in Selenium?

Run driver.execute_script('arguments[0].scrollIntoView()', lastItem) or use Actions.scroll_to_element in Selenium 4, then use WebDriverWait to wait until the number of items increases. Loop until no new items appear.

What is the difference between lazy loading and pagination?

Pagination splits content across pages the user navigates. Lazy loading or infinite scroll appends items to the same page as the user scrolls. Tests for lazy loading need scroll actions and waits, while pagination tests click next and check the URL or content.

Why does my element not exist until I scroll?

The page only renders it after it enters the viewport, usually via IntersectionObserver. Scroll to the container first, wait for the element, then interact. Locating it before scrolling will fail with a not found or timeout error.

Can I check lazy loaded images in a test?

Yes. Scroll the image into view, then assert its naturalWidth is greater than zero or that the src attribute is populated. Playwright can evaluate this in the page, and Cypress can use invoke on the element.

Free developer tools on Randomly.online

QA Playground is part of Randomly.online. These tools help while you write and debug tests: