blob: 2182a5d8291eb9ab72ba2cab4f19a3a7ce175ad3 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
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;
}
}
|