-
Notifications
You must be signed in to change notification settings - Fork 0
/
indexHtmPageFunction.ts
61 lines (48 loc) · 1.87 KB
/
indexHtmPageFunction.ts
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
51
52
53
54
55
56
57
58
59
60
61
//Tinkering with writing this as a function Vs a class
import { expect, Page } from '@playwright/test';
import { goToIndexHtm } from '@scripts/navigation';
export const indexHtmPageFunction = (page: Page) => {
const goto = async () => {
await goToIndexHtm(page);
};
const verifyPageTitle = async (pageTitle: string) => {
await expect(page).toHaveTitle(pageTitle);
};
const verifyIndexPageCopyIntro = async (indexPageCopy: string) => {
await expect(page.locator('[data-testid="intro-page-copy"]')).toHaveText(indexPageCopy);
};
const clickWeatherAlertLink = async () => {
await page.locator('a', { hasText: 'View weather alerts on my page' }).click();
};
const clickFeedbackWidget = async () => {
await page.locator('[class="widget__actor__text"]').click();
};
const fillFeedbackWidgetNameField = async (widgetNameField: string) => {
await page.locator('[id="name"]').fill(widgetNameField);
};
const fillFeedbackWidgetEmailField = async (widgetEmailField: string) => {
await page.locator('[id="email"]').fill(widgetEmailField);
};
const fillFeedbackWidgetMessageField = async (widgetMessageField: string) => {
await page.locator('[id="message"]').fill(widgetMessageField);
};
const clickFeedbackWidgetSendNowButton = async () => {
await page.getByLabel('Send Now!').click();
};
const verifyFeedbackWidgetMessageSent = async (widgetMessageSent: string, options: { ignoreCase: boolean } ) => {
await page.waitForTimeout(1000);
expect(page.locator('.success-message')).toContainText(widgetMessageSent, options);
};
return {
goto,
verifyPageTitle,
verifyIndexPageCopyIntro,
clickWeatherAlertLink,
clickFeedbackWidget,
fillFeedbackWidgetNameField,
fillFeedbackWidgetEmailField,
fillFeedbackWidgetMessageField,
clickFeedbackWidgetSendNowButton,
verifyFeedbackWidgetMessageSent
};
};