-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcheckout.po.ts
43 lines (38 loc) · 1.21 KB
/
checkout.po.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
import { Locator, Page } from '@playwright/test'
import { ShoppingCart } from './shoppingCart.po'
import { OverviewCheckout } from './overviewCheckout.po'
export class Checkout {
readonly page: Page
readonly firstName: Locator
readonly lastName: Locator
readonly postalCode: Locator
readonly continueButton: Locator
readonly cancelButton: Locator
readonly errorMessage: Locator
constructor(page: Page) {
this.page = page
this.firstName = page.getByTestId('firstName')
this.lastName = page.getByTestId('lastName')
this.postalCode = page.getByTestId('postalCode')
this.continueButton = page.getByTestId('continue')
this.cancelButton = page.getByTestId('cancel')
this.errorMessage = page.getByTestId('error')
}
async fillOutForm(
firstName?: string,
lastName?: string,
postalCode?: string
) {
firstName && (await this.firstName.fill(firstName))
lastName && (await this.lastName.fill(lastName))
postalCode && (await this.postalCode.fill(postalCode))
}
async continue() {
await this.continueButton.click()
return new OverviewCheckout(this.page)
}
async cancel() {
await this.cancelButton.click()
return new ShoppingCart(this.page)
}
}