forked from clerk/javascript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommonPageObject.ts
More file actions
56 lines (54 loc) · 1.76 KB
/
Copy pathcommonPageObject.ts
File metadata and controls
56 lines (54 loc) · 1.76 KB
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
import type { TestArgs } from './signInPageObject';
export const common = ({ page }: TestArgs) => {
const self = {
continue: () => {
return page.getByRole('button', { name: 'Continue', exact: true }).click();
},
setEmailAddress: (val: string) => {
return self.getEmailAddressInput().fill(val);
},
setPassword: (val: string) => {
return self.getPasswordInput().fill(val);
},
setPasswordConfirmation: (val: string) => {
return page.locator('input[name=confirmPassword]').fill(val);
},
enterOtpCode: async (code: string) => {
await page.getByRole('textbox', { name: /digit 1/i }).click();
await page.keyboard.type(code, { delay: 50 });
},
enterTestOtpCode: async () => {
return self.enterOtpCode('424242');
},
// It's recommended to use .fill instead of .type
// @see https://playwright.dev/docs/api/class-keyboard#keyboard-type
fillTestOtpCode: async (name: string) => {
return page.getByRole('textbox', { name: name }).fill('424242');
},
getIdentifierInput: () => {
return page.locator('input[name=identifier]');
},
getEmailAddressInput: () => {
return page.locator('input[name=emailAddress]');
},
getPhoneNumberInput: () => {
return page.locator('input[name=phoneNumber]');
},
getUsernameInput: () => {
return page.locator('input[name=username]');
},
getPasswordInput: () => {
return page.locator('input[name=password]');
},
getLegalAccepted: () => {
return page.locator('input[name=legalAccepted]');
},
getFirstNameInput: () => {
return page.locator('input[name=firstName]');
},
getLastNameInput: () => {
return page.locator('input[name=lastName]');
},
};
return self;
};