Store Lazy Loading
Challenge Tasks (3)
Tick a task when your script passes it. Tasks with a pass/fail box tick themselves.
Practice interacting with dynamic infinite scroll and waiting for network calls to finish.
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.
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: