package com.utopiadeals.web.pages; import com.microsoft.playwright.BrowserContext; import com.microsoft.playwright.Locator; import com.microsoft.playwright.Page; import com.microsoft.playwright.Response; import static com.utopiadeals.framework.BrowserContextManager.getBrowserContext; import static com.utopiadeals.framework.BrowserContextManager.getPage; public class BasePage { private final BrowserContext browserContext; private final Page page; private Response pageResponse; public BasePage() { this.browserContext = getBrowserContext(); this.page = getPage(); } public void navigate(String url) { this.pageResponse = page.navigate(url); } protected Locator locator(String selector) { return page.locator(selector); } protected Locator getByText(String text) { return page.getByText(text); } protected void click(Locator locator) { locator.click(); // Auto-waiting built-in - no need for explicit waits! } protected void clear(Locator locator) { locator.clear(); } protected void fill(Locator locator, String text) { locator.fill(text); } protected String getText(Locator locator) { return locator.textContent().trim(); } protected boolean isVisible(Locator locator) { return locator.isVisible(); } public Response getPageResponse() { return pageResponse; } }