Test Automation Design Patterns Visualizer
This free design patterns visualizer shows the patterns that keep a test automation framework maintainable — Page Object Model, Factory, Singleton and Builder — applied to a real framework rather than abstract textbook examples. It is built for SDETs designing frameworks and for the "how is your framework structured?" question that defines senior interviews.
Page Object Model (POM)
The Page Object Model wraps each page or component in a class that exposes actions (loginPage.login(user, pass)) and hides the locators. When the UI changes, you fix one page object, not fifty tests. This is the single most important pattern in UI automation and the one every interview probes.
Factory pattern for drivers
A DriverFactory centralises how WebDriver instances are created, so switching from Chrome to Firefox, or local to a remote grid, is one change in one place. It keeps browser-setup logic out of your tests and makes cross-browser runs trivial.
Singleton and ThreadLocal
A naive Singleton WebDriver breaks under parallel execution because every thread shares one browser. The correct pattern is a ThreadLocal driver: one isolated instance per thread, which is why this comes up whenever parallel testing does.
Builder pattern for test data
The Builder pattern constructs complex test data readably: new UserBuilder().withRole("admin").withVerifiedEmail().build(). It beats constructors with ten arguments and makes each test state its intent, keeping data setup clean as the suite grows.
How to use this tool
- Pick a pattern in the tool and see it applied to a sample framework.
- Compare a test written with and without the Page Object Model.
- See why a Singleton driver fails in parallel and how ThreadLocal fixes it.
- Build a test-data object with the Builder pattern step by step.
Worked example
A Page Object hides locators behind intention-revealing methods:
public class LoginPage {
private final WebDriver driver;
private final By user = By.id("username");
private final By pass = By.id("password");
private final By submit = By.cssSelector("button[type=submit]");
public LoginPage(WebDriver driver) { this.driver = driver; }
public HomePage login(String u, String p) {
driver.findElement(user).sendKeys(u);
driver.findElement(pass).sendKeys(p);
driver.findElement(submit).click();
return new HomePage(driver);
}
}
Tests call loginPage.login(u, p) and never touch a locator directly. Common mistakes to avoid
- Putting assertions inside page objects — page objects model the page, tests own the assertions.
- A shared Singleton WebDriver that breaks the moment tests run in parallel.
- Constructors with many arguments instead of a Builder for test data.
- Over-engineering: adding patterns a small framework does not need yet.
Frequently asked questions
What is the Page Object Model?
A design pattern where each page or component is a class that exposes actions and hides its locators, so a UI change is fixed in one place instead of across many tests.
Why use a Factory for WebDriver?
A DriverFactory centralises driver creation so switching browser or moving from local to a remote grid is a single change, and browser setup stays out of the tests.
Why is a Singleton WebDriver a problem in parallel tests?
All threads would share one browser. A ThreadLocal driver gives each thread its own isolated instance, which is the correct pattern for parallel execution.
When should I use the Builder pattern?
For constructing complex, readable test data without long constructors — for example building a user with specific roles and states.
Is this design patterns tool free?
Yes, it runs in your browser with nothing to install and is free for learning and interview prep.