Quick interview answer
Keep page objects for pages, but extract reusable widgets (header, data grid, date picker, modal) as component objects that take a root locator and are composed into pages.
Detailed explanation
Modern apps are built from components, so a pure page-per-URL model duplicates the same grid or dialog code across many pages. A component object scopes all its lookups to a root element, so two instances of the same widget on one page do not collide. Pages then become thin compositions that expose business actions. Avoid PageFactory's @FindBy with lazy proxies if your app re-renders heavily — resolving locators at call time is more predictable, and returning the next page object from navigation methods keeps flows readable.
1public class DataGrid {2 private final SearchContext root;3 private final WebDriver driver;4 5 public DataGrid(WebDriver driver, By rootLocator) {6 this.driver = driver;7 this.root = driver.findElement(rootLocator);8 }9 10 public List<String> column(String header) { /* scoped lookups only */ }11 public void sortBy(String header) { /* ... */ }12}… 4 more linesReal-world example
Three pages shared the same results grid; extracting one component object deleted about 400 duplicated lines.
Interview tip
Explain the root-locator scoping — it is the detail that distinguishes component objects from a renamed page object.
