Member-only story

Automated Testing Elements on a Lazy Load Page with Selenium WebDriver

How to verify elements that get dynamically loaded on a page using Selenium WebDriver

Zhimin Zhan
5 min readDec 5, 2022

A repost of my daughter’s article with permission. I added a few notes. This is also included in my “How to in Selenium WebDriver” series.

Zhimin’s notes:

Three years ago, I consulted on a Microsoft Dynamics 365 CRM project. I developed one automated (UI) test for a core end-to-end workflow. The project manager did not expect that, after seeing the test execution, he said: “I have never seen automating Dynamics 365 like this (driving UI) and you did that on the first day. What testing tools did you use?”

My answer: “Raw Selenium WebDriver”.
The PM said: “I was told by automated testers, more than once, that Selenium or others, unable to drive Dynamics 365, because it is lazy loading”.
I replied: “Oh well, you are seeing it now”.

In this article, Courtney shows two approaches to automated-testing lazy-load web pages.

Advice on automating Microsoft web apps. The lazy loading in Dynamics 365 is not obvious as the example used in this article. Futhermore, combined with multiple frames used in Microsoft D365 and SharePoint pages, it can be overwhelming. However, if you understand automating frames and lazy-loading well, using a good tool such as TestWise, it is not that hard. A feature like TestWise’s “Attach test execution to the existing browser” will be very helpful.

Some modern websites now use lazy loading (also known as progressive loading). Instead of loading everything on the page at once, the items load as you scroll. This brings challenges to test automation, because the element we want to control may not be displayed yet. An example site is Substack, if you scroll down on this site, you will notice the bottom of this page reloads more articles.

This article will show you how to use Selenium WebDriver to force lazy-loaded pages to load your desired element, and drive it.

Test Design

  1. Look for the element on the page
  2. If the element is not there, scroll down the page
  3. Repeat steps 1–2

1. Look for the element on the…

--

--

Zhimin Zhan
Zhimin Zhan

Written by Zhimin Zhan

Test automation & CT coach, author, speaker and award-winning software developer. Help teams succeed with Agile/DevOps by implementing real Continuous Testing.

No responses yet

Write a response