aboutsummaryrefslogtreecommitdiff
path: root/src/test/java/webui/pages/ApplicationPage.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/java/webui/pages/ApplicationPage.java')
-rw-r--r--src/test/java/webui/pages/ApplicationPage.java50
1 files changed, 50 insertions, 0 deletions
diff --git a/src/test/java/webui/pages/ApplicationPage.java b/src/test/java/webui/pages/ApplicationPage.java
new file mode 100644
index 0000000..2182a5d
--- /dev/null
+++ b/src/test/java/webui/pages/ApplicationPage.java
@@ -0,0 +1,50 @@
+package webui.pages;
+
+import static com.microsoft.playwright.assertions.PlaywrightAssertions.*;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+import java.net.URL;
+
+import com.microsoft.playwright.Locator;
+import com.microsoft.playwright.Page;
+import com.microsoft.playwright.Response;
+import com.microsoft.playwright.options.AriaRole;
+
+/**
+ * Provide abstract class to track Pantry-wide locators, components, integrations, and tests
+ */
+public abstract class ApplicationPage {
+
+ private static final String TOAST_DIV_SELECTOR = "div#toast-holder";
+
+ protected final Page page;
+
+ public ApplicationPage(Page page) {
+ this.page = page;
+ }
+
+ /**
+ * Navigate to page with table of Pantry Items
+ */
+ public void loadAndVerifyPage(URL location, String title) {
+ Response response = page.navigate(location.toString());
+ assertEquals("OK", response.statusText());
+
+ page.waitForLoadState();
+
+ assertThat(page).hasTitle(title);
+ }
+
+
+ /**
+ * Assert that a notification is displayed with the specified header and text
+ */
+ public Locator findAndValidateNotification(final String header, final String text) {
+ Locator specifiedNotification = page.locator(TOAST_DIV_SELECTOR)
+ .getByRole(AriaRole.ALERT)
+ .filter(new Locator.FilterOptions().setHasText(text));
+ assertThat(specifiedNotification).isVisible();
+ assertThat(specifiedNotification).containsText(header);
+ return specifiedNotification;
+ }
+} \ No newline at end of file