Power Your Software Testing with AI Agents and Cloud
The Native AI-Agentic Cloud Platform to Supercharge Quality Engineering. Test Intelligently and Ship Faster.
- TestMu AI (Formerly LambdaTest)
- /
- Blog
- /
- Make Your Test Robust For Slow Loading Web Pages
Loadable Components In Selenium: Make Your Test Robust For Slow Loading Web Pages
The Selenium LoadableComponent class extends PageObject to check isLoaded() and retry load(), keeping automation tests reliable on slow-loading web pages.
Last Updated on:
On This Page
A Loadable Component in Selenium is a PageObject that extends the LoadableComponent class, checks isLoaded(), and calls load() again when a page has not finished rendering. The get() method calls isLoaded() first and only falls back to load(), so the retry happens automatically instead of a fixed sleep or a hardcoded delay. This guide covers extending LoadableComponent, implementing load() and isLoaded(), a Java PageObject example, and how AI-driven wait strategies now handle the same slow-loading-page problem.
Key Takeaways
- The Selenium LoadableComponent class wraps a PageObject and confirms a page fully loaded before a test continues.
- The isLoaded() method throws java.lang.Error when the page has not rendered, and load() supplies the retry.
- The get() method calls isLoaded() first and only calls load() as a fallback, avoiding a hardcoded sleep.
- Selenium's explicit and implicit waits solve a narrower problem than LoadableComponent: they wait for one element, not full page or component state.
- Flaky Selenium tests on JavaScript-heavy pages are a common trigger for adopting the LoadableComponent pattern.
- AI-driven test agents now check DOM stability and network activity instead of a single fixed timeout, reducing how often a team hand-codes a new LoadableComponent.
The component that’s gonna help us in page loading is an extended version of Page Object Model pattern called Loadable component. The Selenium LoadableComponent class extends PageObject to check isLoaded() and retry load(), keeping automation tests reliable on slow-loading web pages.
On a side note, to make your life of testing easy and fuss-free while debugging, you can try the LT Debug Chrome extension.
To start with, we would first have to make sure that all the PageObject classes extends the abstract LoadableComponent class and in turn provide implementation for the following two methods:
- protected abstract void load()
- protected abstract void isLoaded() throws java.lang.Error
Code to ensure whether the page or component inside the page is completely loaded in given in isLoaded(). If the page is not completely loaded, java.lang.Error is thrown
Fallback or mitigation code is given load(), if isLoaded() fails to load the complete page successfully.
Let’s take an example on how it works :
Suppose, we have a LoginPage with username, password and submit button.
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.CacheLookup;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.PageFactory;
public class LoginPage {
private WebDriver driver;
@FindBy(id = "login_username")
private WebElement usernameInputBox;
@FindBy(id = "login_password")
private WebElement passwordInputBox;
@FindBy(id = "login_submit")
private WebElement loginButton;
public AdminLoginPageUsingLoadableComponent(WebDriver driver){
this.driver = driver;
PageFactory.initElements(driver, this);
}
public NextPage login(String loginUsername, String loginPassword){
usernameInputBox.sendKeys(loginUsername");
passwordInputBox.sendKeys(loginPassword");
loginButton.click();
return PageFactory.initElements(driver, NextPage.class);
}
}
Now, the above PageObject can be transformed using LoadableCompenent like below.
import org.junit.Assert;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.CacheLookup;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.PageFactory;
import org.openqa.selenium.support.ui.LoadableComponent;
public class LoginPageUsingLoadableComponent extends LoadableCompenent {
private WebDriver driver;
@FindBy(id = "login_username")
private WebElement usernameInputBox;
@FindBy(id = "login_password")
private WebElement passwordInputBox;
@FindBy(id = "login_submit")
private WebElement loginButton;
public LoginPageUsingLoadableComponent(WebDriver driver){
this.driver = driver;
PageFactory.initElements(driver, this);
}
public NextPage login(String loginUsername, String loginPassword){
usernameInputBox.sendKeys(loginUsername");
passwordInputBox.sendKeys(loginPassword");
loginButton.click();
return PageFactory.initElements(driver, NextPage.class);
}
@Override
protected void load() {
driver.get("http://www.example.com/login");
}
@Override
protected void isLoaded() throws Error {
Assert.assertTrue(driver.getCurrentUrl().contains("login"));
}
}
LoginPageUsingLoadableComponent loginPage = new LoginPageUsingLoadableComponent(driver).get();
The get() method from the LoadableComponent class will ensure sure the page or the component is loaded by invoking the isLoaded() method. If the assertion fails there, load() method is called, followed by isLoaded().
How Do AI Testing Agents Handle Slow-Loading Pages Now?
AI-driven test agents now handle page-load synchronization without hand-written LoadableComponent boilerplate, using signals a fixed timeout cannot see.
- Self-healing waits: an agent built on AI tools for preventing flaky tests watches DOM mutations and network idle time instead of one fixed timeout, so it waits only as long as the page actually needs.
- Visual stability checks: some agentic tools compare successive screenshots and treat a page as loaded only when pixels stop changing, which catches a slow-rendering JavaScript framework that a single element check misses.
- Fewer flaky reruns: removing a fixed wait cuts one of the most common causes of flaky Selenium tests on pages that render at inconsistent speeds.
- Wait strategies still apply: most Selenium Java projects still pair this pattern with explicit and implicit waits for individual elements, while the agent handles page-level readiness.
- Assertions stay unchanged: the isLoaded() check still relies on a standard assertion library such as TestNG or JUnit, since AI changes how long the agent waits, not the assertion itself.
None of this removes the LoadableComponent pattern. It changes how often a team needs to hand-code one.
Hope this article helps in stabilizing UI tests !!!
Austin Siewert
Co-Founder, Steadfast Systems
Discovered @TestMu AI yesterday. Best browser testing tool I've found for my use case. Great pricing model for the limited testing I do 👏
2M+ Devs and QAs rely on TestMu AI
Deliver immersive digital experiences with Next-Generation Mobile Apps and Cross Browser Testing Cloud
Author
Aditya Kumar Dwivedi is a Senior QA Engineer with 7+ years of experience in manual testing, UI automation, and API testing across web and mobile applications. He specializes in automation framework development from scratch using Selenium, Playwright, Appium, REST Assured, and Cucumber, with strong experience integrating tests into CI/CD pipelines using Jenkins. Aditya has worked extensively in Agile environments, contributing to scalable test architectures, efficient testing workflows, and reliable software releases, including hands-on experience at TestMu AI.
Loadable Component in Selenium FAQs
Did you find this page helpful?
More Related Blogs
TestMu AI forEnterprise
Get access to solutions built on Enterprise
grade security, privacy, & compliance
- Advanced access controls
- Advanced data retention rules
- Advanced Local Testing
- Premium Support options
- Early access to beta features
- Private Slack Channel
- Unlimited Manual Accessibility DevTools Tests


