Skip to content

Commit

Permalink
Custome test data fixture addition
Browse files Browse the repository at this point in the history
  • Loading branch information
An5hul-Choudhary committed Apr 22, 2024
1 parent 96bec50 commit 78e50d0
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 7 deletions.
9 changes: 8 additions & 1 deletion Utils/EndToEndPageObjectTestData.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
[
{
"email" : "anshika222@gmail.com",
"password" : "Iamking@000",
"productName": "ADIDAS ORIGINAL"
}
},
{
"email" : "rahulshetty@gmail.com",
"password" : "Iamking@000",
"productName": "ZARA COAT 3"
}
]
13 changes: 13 additions & 0 deletions Utils/test-base.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
const base = require('@playwright/test')

exports.customtest = base.test.extend(
{
testDataForOrder :{

email : "anshika222@gmail.com",
password : "Iamking@000",
productName: "ADIDAS ORIGINAL"

}
}
)
47 changes: 41 additions & 6 deletions tests/EndToEndPageObject.spec.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
const { test, expect } = require('@playwright/test');
const {customtest} = require('../Utils/test-base');
const {POManager} = require('../PageObjects/POManager');
//JSON -> String -> JS object
const dataSet = JSON.parse(JSON.stringify(require('../Utils/EndToEndPageObjectTestData.json')));


test('@Client App login', async ({ page }) => {
for(const data of dataSet){

test(`@Client App login for ${data.productName}`, async ({ page }) => {
//js file- Login js, DashboardPage
const poManager = new POManager(page);

const loginPage = poManager.getLoginPage();
await loginPage.goto();
await loginPage.validLogin(dataSet.email, dataSet.password);
await loginPage.validLogin(data.email, data.password);

const dashboardPage = poManager.getDashboardPage();
await dashboardPage.searchProduct(dataSet.productName);
await dashboardPage.searchProduct(data.productName);
await dashboardPage.navigateToCart();

const cartPage = poManager.getCartPage();
Expand All @@ -22,7 +24,7 @@ test('@Client App login', async ({ page }) => {

const paymentPage = poManager.getPaymentPage();
await paymentPage.selectCountry("ind", " India");
await paymentPage.validatingEmail(dataSet.email);
await paymentPage.validatingEmail(data.email);

const thankyouPage = poManager.getThankyouPage();
const orderId = await thankyouPage.validateOrderId();
Expand All @@ -35,4 +37,37 @@ test('@Client App login', async ({ page }) => {

});


}



customtest.only("@Client App login with test data fixture", async ({ page, testDataForOrder }) => {
//js file- Login js, DashboardPage
const poManager = new POManager(page);

const loginPage = poManager.getLoginPage();
await loginPage.goto();
await loginPage.validLogin( testDataForOrder.email, testDataForOrder.password);

const dashboardPage = poManager.getDashboardPage();
await dashboardPage.searchProduct( testDataForOrder.productName);
await dashboardPage.navigateToCart();

const cartPage = poManager.getCartPage();
await cartPage.checkAddedProduct();
await cartPage.checkOut();

const paymentPage = poManager.getPaymentPage();
await paymentPage.selectCountry("ind", " India");
await paymentPage.validatingEmail( testDataForOrder.email);

const thankyouPage = poManager.getThankyouPage();
const orderId = await thankyouPage.validateOrderId();
console.log(orderId);
await thankyouPage.myOrder();

const orderDetailsPage = poManager.getOrderDetailsPage();
await orderDetailsPage.selectingOrderDetails(orderId);
await orderDetailsPage.validatingOrderDetails(orderId);

});

0 comments on commit 78e50d0

Please sign in to comment.