WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Commit 7f08cd5

Browse files
authored
Merge pull request #20 from auto-qa-hub/po-for-checkout
po-for-checkout-steps
2 parents 0ebec5e + 1575612 commit 7f08cd5

File tree

4 files changed

+120
-1
lines changed

4 files changed

+120
-1
lines changed

fixtures/usersBillingData.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
"firstname": "TestName",
33
"lastname": "TestLastName",
4-
"zip": 92618
4+
"zip": "92618"
55
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import { Locator, expect, Page } from "@playwright/test";
2+
export class CheckoutCompletePage {
3+
page: Page;
4+
confirmationMessage: Locator;
5+
orderStatusMessage: Locator;
6+
backHomeButton: Locator;
7+
8+
constructor(page: Page) {
9+
this.page = page;
10+
this.confirmationMessage = page.locator(".complete-header");
11+
this.orderStatusMessage = page.locator(".complete-text");
12+
this.backHomeButton = page.locator('[data-test="back-to-products"]');
13+
}
14+
15+
async getConfirmationMessage(): Promise<string> {
16+
return (await this.confirmationMessage.textContent()) ?? "";
17+
}
18+
19+
async getOrderStatusMessage(): Promise<string> {
20+
return (await this.orderStatusMessage.textContent()) ?? "";
21+
}
22+
23+
async clickBackHome(): Promise<void> {
24+
await this.backHomeButton.click();
25+
}
26+
27+
async verifyPageElements(): Promise<void> {
28+
await expect(this.confirmationMessage).toHaveText( "Thank you for your order!");
29+
await expect(this.orderStatusMessage).toContainText("Your order has been dispatched");
30+
await expect(this.backHomeButton).toBeVisible();
31+
}
32+
}
33+
34+
module.exports = { CheckoutCompletePage };
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import { Locator, Page } from "@playwright/test";
2+
export class CheckoutStepOnePage{
3+
page: Page;
4+
firstNameInput: Locator;
5+
lastNameInput: Locator;
6+
zipCodeInput: Locator;
7+
continueButton: Locator;
8+
cancelButton: Locator;
9+
errorMessage: Locator;
10+
11+
constructor(page: Page) {
12+
this.page = page;
13+
this.firstNameInput = page.locator("#first-name");
14+
this.lastNameInput = page.locator("#last-name");
15+
this.zipCodeInput = page.locator("#postal-code");
16+
this.continueButton = page.locator("#continue");
17+
this.cancelButton = page.locator("#cancel");
18+
this.errorMessage = page.locator('[data-test="error"]');
19+
}
20+
21+
async enterCheckoutDetails(firstName: string, lastName: string, zipCode: string) {
22+
await this.firstNameInput.fill(firstName);
23+
await this.lastNameInput.fill(lastName);
24+
await this.zipCodeInput.fill(zipCode);
25+
}
26+
27+
async submitCheckout() {
28+
await this.continueButton.click();
29+
}
30+
31+
async cancelCheckout() {
32+
await this.cancelButton.click();
33+
}
34+
35+
async getErrorMessage(): Promise<string> {
36+
return await this.errorMessage.innerText();
37+
}
38+
}
39+
module.exports = { CheckoutStepOnePage };
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import { Locator, Page } from "@playwright/test";
2+
export class CheckoutStepTwoPage{
3+
page: Page;
4+
productNames: Locator;
5+
itemTotal: Locator;
6+
taxAmount: Locator;
7+
totalAmount: Locator;
8+
finishButton: Locator;
9+
cancelButton: Locator;
10+
11+
constructor(page: Page) {
12+
this.page = page;
13+
this.productNames = page.locator(".inventory_item_name");
14+
this.itemTotal = page.locator(".summary_subtotal_label");
15+
this.taxAmount = page.locator(".summary_tax_label");
16+
this.totalAmount = page.locator(".summary_total_label");
17+
this.finishButton = page.locator("#finish");
18+
this.cancelButton = page.locator("#cancel");
19+
}
20+
21+
async getProductNames(): Promise<string[]> {
22+
return await this.productNames.allTextContents();
23+
}
24+
25+
async getItemTotal(): Promise<string> {
26+
return await this.itemTotal.innerText();
27+
}
28+
29+
async getTaxAmount(): Promise<string> {
30+
return await this.taxAmount.innerText();
31+
}
32+
33+
async getTotalAmount(): Promise<string> {
34+
return await this.totalAmount.innerText();
35+
}
36+
37+
async completeCheckout() {
38+
await this.finishButton.click();
39+
}
40+
41+
async cancelCheckout() {
42+
await this.cancelButton.click();
43+
}
44+
}
45+
46+
module.exports = { CheckoutStepTwoPage };

0 commit comments

Comments
 (0)