Skip to content

Commit 7ee6154

Browse files
committed
add steps and snippets for the checkout feature
1 parent 6cb7e1d commit 7ee6154

File tree

5 files changed

+84
-1
lines changed

5 files changed

+84
-1
lines changed

fixtures/pageFixtures.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,14 @@ import { BasePage } from "../pages/BasePage";
33
import { LoginPage } from "../pages/LoginPage";
44
import { RegistrationPage } from "../pages/RegistrationPage";
55
import { ProductPage } from "../pages/ProductPage";
6+
import { CheckoutPage } from "../pages/CheckoutPage";
67

78
type MyFixtures = {
89
basePage: BasePage;
910
loginPage: LoginPage;
1011
registrationPage: RegistrationPage;
1112
productPage: ProductPage;
13+
checkoutPage: CheckoutPage;
1214
//add more types here
1315
};
1416

@@ -25,5 +27,8 @@ export const test = base.extend<MyFixtures>({
2527
productPage: async ({ page }, use) => {
2628
await use(new ProductPage(page));
2729
},
30+
checkoutPage: async ({ page }, use) => {
31+
await use(new CheckoutPage(page));
32+
},
2833
//define others similarly
2934
});

pages/CheckoutPage.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { Page, Locator, expect } from "@playwright/test";
2+
3+
export class CheckoutPage {
4+
readonly page: Page;
5+
//TODO: Define locators for checkout page elements here
6+
7+
constructor(page: Page) {
8+
this.page = page;
9+
}
10+
11+
// Add methods for checkout page interactions as needed
12+
}

tests/features/add-to-cart.feature

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
@wip
1+
@addToCart
22
Feature: Add items to shopping cart
33

44
As a user

tests/features/checkout.feature

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
@checkout
2+
Feature: Checkout
3+
Given the user is on the homepage
4+
5+
Scenario Outline: Verify user can checkout successfully
6+
When the user selects a product "Thor Hammer"
7+
And the user clicks add to cart button
8+
And user clicks shopping cart icon
9+
And user click proceed to checkout button
10+
And user logs in
11+
And user click proceed to checkout button
12+
And user fills in the shipping address details and click proceeds to checkout button
13+
And user select payment method <"payment-method">
14+
And user enters valid payment details for <"payment-method">
15+
And user clicks confirm button
16+
Then user should see an order confirmation message
17+
18+
Examples:
19+
| payment-method |
20+
| Bank Transfer |
21+
| Cash on Delivery |
22+
| Credit Card |
23+
| Buy Now Pay Later |
24+
| Gift Card |
25+
26+
#TODO Scenario with logged in user before adding to cart
27+
#TODO Scenario with continuing as guest user

tests/steps/checkout.steps.ts

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import { Given, When, Then } from "@cucumber/cucumber";
2+
3+
When("user clicks shopping cart icon", async function () {
4+
5+
});
6+
7+
When("user click proceed to checkout button", async function () {
8+
9+
});
10+
11+
When("user logs in", async function () {
12+
13+
});
14+
15+
When(
16+
"user fills in the shipping address details and click proceeds to checkout button",
17+
async function () {
18+
19+
}
20+
);
21+
22+
When("user select payment method <{string}>", async function (string) {
23+
24+
});
25+
26+
When(
27+
"user enters valid payment details for <{string}>",
28+
async function (string) {
29+
=
30+
}
31+
);
32+
33+
When("user clicks confirm button", async function () {
34+
35+
});
36+
37+
Then("user should see an order confirmation message", async function () {
38+
39+
});

0 commit comments

Comments
 (0)