-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
54f4cf0
commit be0a57c
Showing
5 changed files
with
150 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
const { expect } = require('@playwright/test'); | ||
|
||
class CartPage{ | ||
|
||
constructor(page){ | ||
this.page = page; | ||
this.firstListItem = page.locator("div li"); | ||
this.addedProduct = page.locator("h3:has-text('ADIDAS ORIGINAL')"); | ||
this.checkoutBtn = page.locator("text=Checkout"); | ||
} | ||
|
||
async checkAddedProduct(){ | ||
await this.firstListItem.first().waitFor(); | ||
const bool = await this.addedProduct.isVisible(); | ||
expect(bool).toBeTruthy(); | ||
} | ||
|
||
async checkOut(){ | ||
await this.checkoutBtn.click(); | ||
} | ||
|
||
} | ||
module.exports = {CartPage}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
class DashboardPage{ | ||
|
||
constructor(page){ | ||
this.products = page.locator(".card-body"); | ||
this.productsText = page.locator(".card-body b"); | ||
this.cart = page.locator("[routerlink*='cart']"); | ||
} | ||
|
||
async searchProduct(productName){ | ||
|
||
await this.productsText.first().waitFor(); | ||
const titles = await this.productsText.allTextContents(); | ||
console.log(titles); | ||
const count = await this.products.count(); | ||
for (let i = 0; i < count; ++i) { | ||
if (await this.products.nth(i).locator("b").textContent() === productName) { | ||
//add to cart | ||
await this.products.nth(i).locator("text= Add To Cart").click(); | ||
break; | ||
} | ||
} | ||
} | ||
|
||
async navigateToCart(){ | ||
await this.cart.click(); | ||
} | ||
|
||
} | ||
module.exports = {DashboardPage}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
class LoginPage{ | ||
|
||
constructor(page){ | ||
this.page = page; | ||
this.userName = page.locator("#userEmail"); | ||
this.passWord = page.locator("#userPassword"); | ||
this.signInBtn = page.locator("[value='Login']"); | ||
} | ||
|
||
async goto(){ | ||
await this.page.goto("https://rahulshettyacademy.com/client"); | ||
} | ||
|
||
async validLogin(email, password){ | ||
await this.userName.fill(email); | ||
await this.passWord.fill(password); | ||
await this.signInBtn.click(); | ||
await this.page.waitForLoadState('networkidle'); | ||
} | ||
} | ||
module.exports = {LoginPage}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
class PaymentPage{ | ||
|
||
constructor(page){ | ||
this.page = page; | ||
this.country = page.locator("[placeholder*='Country']"); | ||
} | ||
|
||
async selectCountry(){ | ||
await this.country.pressSequentially("ind"); | ||
} | ||
} | ||
module.exports = {PaymentPage}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
const { test, expect } = require('@playwright/test'); | ||
const {LoginPage} = require('../PageObjects/LoginPage'); | ||
const {DashboardPage} = require('../PageObjects/DashboardPage'); | ||
const {CartPage} = require('../PageObjects/CartPage'); | ||
const {PaymentPage} = require('../PageObjects/PaymentPage'); | ||
|
||
|
||
test('@Client App login', async ({ page }) => { | ||
//js file- Login js, DashboardPage | ||
const email = "anshika222@gmail.com"; | ||
const password = "Iamking@000"; | ||
const productName = 'ADIDAS ORIGINAL'; | ||
|
||
const loginPage = new LoginPage(page); | ||
|
||
await loginPage.goto(); | ||
await loginPage.validLogin(email, password); | ||
|
||
const dashboardPage = new DashboardPage(page); | ||
await dashboardPage.searchProduct(productName); | ||
await dashboardPage.navigateToCart(); | ||
|
||
const cartPage = new CartPage(page); | ||
cartPage.checkAddedProduct(); | ||
cartPage.checkOut(); | ||
|
||
const paymentPage = new PaymentPage(page); | ||
paymentPage.selectCountry(); | ||
|
||
const dropdown = page.locator(".ta-results"); | ||
await dropdown.waitFor(); | ||
const optionsCount = await dropdown.locator("button").count(); | ||
for (let i = 0; i < optionsCount; ++i) { | ||
const text = await dropdown.locator("button").nth(i).textContent(); | ||
if (text === " India") { | ||
await dropdown.locator("button").nth(i).click(); | ||
break; | ||
} | ||
} | ||
|
||
await expect(page.locator(".user__name [type='text']").first()).toHaveText(email); | ||
await page.locator(".action__submit").click(); | ||
await expect(page.locator(".hero-primary")).toHaveText(" Thankyou for the order. "); | ||
const orderId = await page.locator(".em-spacer-1 .ng-star-inserted").textContent(); | ||
console.log(orderId); | ||
|
||
await page.locator("button[routerlink*='myorders']").click(); | ||
await page.locator("tbody").waitFor(); | ||
const rows = await page.locator("tbody tr"); | ||
|
||
|
||
for (let i = 0; i < await rows.count(); ++i) { | ||
const rowOrderId = await rows.nth(i).locator("th").textContent(); | ||
if (orderId.includes(rowOrderId)) { | ||
await rows.nth(i).locator("button").first().click(); | ||
break; | ||
} | ||
} | ||
const orderIdDetails = await page.locator(".col-text").textContent(); | ||
expect(orderId.includes(orderIdDetails)).toBeTruthy(); | ||
|
||
|
||
}); | ||
|
||
|