Skip to content

Commit 15320f6

Browse files
committed
changed small details
1 parent bc82ccd commit 15320f6

8 files changed

Lines changed: 26 additions & 22 deletions

File tree

pages/LumaMainPage.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -325,10 +325,10 @@ export class LumaMainPage extends BasePage {
325325
/**
326326
* @description clicks on the desired button from a specific row that contains a specific text on a table
327327
*/
328-
public async clickOnTargetButtonFromSpecificTableRow(tableLocator: string, rowText: string, buttonLocator: (string | Locator)) {
329-
const tableRow = this.page.locator(`${tableLocator} tbody tr`, { hasText: rowText });
330-
const tableRowButton = tableRow.locator(buttonLocator);
331-
await this.clickElement(tableRowButton);
328+
public async clickOnTargetButtonFromSpecificTableRow(tableLocator: string, rowText: string, buttonLocator: string) {
329+
const table = this.page.locator(tableLocator, { hasText: rowText });
330+
const tableButton = table.locator(buttonLocator);
331+
await this.clickElement(tableButton);
332332
}
333333

334334
public async validateAllTableCellValues(tableLocator: string, rowText: string, expectedCellValues: string[]) {

pages/cartPage/ShoppingCartPage.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ export class ShoppingCartPage extends LumaMainPage {
1111
private cartItemLocator = '[class="cart item"]';
1212
private moveToWishListLinkName = 'Move to Wishlist'
1313
private updateShoppingCartButtonName = 'Update Shopping Cart'
14-
private shoppingCartTable = '#shopping-cart-table';
14+
private shoppingCartTable = '[class="cart table-wrapper"]';
1515
private subTotalTableColumn = 'Subtotal';
16-
private editCartItemTitle = 'Edit item parameters';
17-
private removeItemTitle = 'Remove item';
16+
private editCartItemLocator = '[class="action action-edit"]';
17+
private removeItemLocator = '[class="action action-delete"]';
1818
private orderTotalLocator = '.grand.totals .amount';
1919
itemShoppingPage: ItemShoppingComponentPage;
2020

@@ -47,11 +47,10 @@ export class ShoppingCartPage extends LumaMainPage {
4747
/**
4848
* @description helper function for modify cart item function
4949
* @param itemText
50-
* @param buttonTitle
50+
* @param buttonLocator
5151
*/
52-
private async clickOnCartTargetButton(itemText: string, buttonTitle: string) {
53-
const targetButton = this.page.getByTitle(buttonTitle);
54-
await this.clickOnTargetButtonFromSpecificTableRow(this.shoppingCartTable, itemText, targetButton);
52+
private async clickOnCartTargetButton(itemText: string, buttonLocator: string) {
53+
await this.clickOnTargetButtonFromSpecificTableRow(this.shoppingCartTable, itemText, buttonLocator);
5554
}
5655
/**
5756
* @description this function clicks on either edit item button or delete an item from cart based on the enum value you choose
@@ -60,10 +59,11 @@ export class ShoppingCartPage extends LumaMainPage {
6059
try {
6160
switch (cartAction) {
6261
case CartActionsEnum.EDIT:
63-
await this.clickOnCartTargetButton(itemName, this.editCartItemTitle);
62+
await this.clickOnCartTargetButton(itemName, this.editCartItemLocator);
6463
break;
6564
case CartActionsEnum.REMOVE:
66-
await this.clickOnCartTargetButton(itemName, this.removeItemTitle);
65+
await this.clickOnCartTargetButton(itemName, this.removeItemLocator);
66+
break;
6767
}
6868
} catch (error) {
6969
throw new Error(`an error occured on function "modifyCartItem": ${error} `)

pages/checkoutPage/CheckOutShippingPage.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ export class CheckoutShippingPage extends LumaMainPage {
5555
await this.fillPostalCode(options?.postalCode!);
5656
await this.selectCountry(options?.country!);
5757
await this.fillPhoneNumber(options?.phoneNumber!);
58-
await this.chooseShippingMethod(options?.shippingMethod!);
5958
}
6059
}
6160

pages/productPage/ProductPage.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export class ProductPage extends LumaMainPage {
1212
private addToWishListLink = 'Add to Wish List';
1313
private addToCompareLink = 'Add to Compare';
1414
private updateCartLocator = '#product-updatecart-button';
15+
private availabilityLocator = '[title="Availability"]'
1516
itemShoppingPage: ItemShoppingComponentPage;
1617

1718
constructor(page: Page) {
@@ -22,11 +23,11 @@ export class ProductPage extends LumaMainPage {
2223
public async validateProductStockAvailability(expectedStockStatus: string) {
2324
let producyAvailibility: ProductStockAvailability | undefined;
2425
const productStock = this.page.locator(this.productInStockLocator);
25-
const stockStatus = await productStock.locator('div').getAttribute('class');
26+
const stockStatus = await productStock.locator(this.availabilityLocator).getAttribute('class');
2627
if (stockStatus === 'stock available') {
2728
producyAvailibility = ProductStockAvailability.IN_STOCK;
2829
} else {
29-
this.productInStockLocator = ProductStockAvailability.OUT_OF_STOCK;
30+
producyAvailibility = ProductStockAvailability.OUT_OF_STOCK;
3031
}
3132
expect(producyAvailibility).toBe(expectedStockStatus);
3233
}

playwright.config.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import { defineConfig, devices } from '@playwright/test';
33
require('dotenv').config();
44

55
export default defineConfig({
6+
globalTimeout: 150000,
7+
timeout: 150000,
68
testDir: './tests',
79
/* Run tests in files in parallel */
810
fullyParallel: true,

tests/menCategoryShoppingTests/BuyFilteredProductFromMenCategory.spec.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,10 @@ test('purchase product from specific category', { tag: ['@MEN_CATEGORY_SHOPPING'
4444
await menCategoryPage.performActionsOnShoppingCart({ cartTotalItems: cartQuantity, clickProceedToCheckout: true })
4545
})
4646
await test.step('fill shipping details, choose shipping method and click on next for payment address validation', async () => {
47-
await checkoutShippingPage.fillShippingDetails({ email, firstname, lastname, country, company, streetFieldIndex: streetFieldIndex, streetAddress, city, state, postalCode, phoneNumber, shippingMethod });
47+
await checkoutShippingPage.fillShippingDetails({ email, firstname, lastname, country, company, streetFieldIndex: streetFieldIndex, streetAddress, city, state, postalCode, phoneNumber });
48+
await checkoutShippingPage.chooseShippingMethod(shippingMethod);
4849
await checkoutShippingPage.clickNext();
49-
await checkoutPaymentPage.validateBillingAndShippingDetails([`${firstname} ${lastname}`, streetAddress, `${city}, ${state} ${postalCode}`, country, phoneNumber])
50+
await checkoutPaymentPage.validateBillingAndShippingDetails([`${firstname} ${lastname}`, streetAddress, `${city}, ${state} ${postalCode}`, country, phoneNumber])
5051
})
5152
await test.step('place order and validate order was successful', async () => {
5253
await checkoutPaymentPage.clickPlaceOrder();

tests/productPurchaseTests/BuyProductEndToEndSanityTest.spec.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ test('Purchase product end to end test', { tag: ['@SANITY'] }, async ({ checkout
3131
await menCategoryPage.performActionsOnShoppingCart({ clickProceedToCheckout: true })
3232
})
3333
await test.step('fill shipping details then click on next', async () => {
34-
await checkoutShippingPage.fillShippingDetails({ signIn: true, email: process.env.EMAIL, password: process.env.PASSWORD, expectedUserAddressDetails, shippingMethod });
34+
await checkoutShippingPage.fillShippingDetails({ signIn: true, email: process.env.EMAIL, password: process.env.PASSWORD, expectedUserAddressDetails });
35+
await checkoutShippingPage.chooseShippingMethod(shippingMethod);
3536
await checkoutShippingPage.clickNext();
3637
})
3738
await test.step('validate cart subtotal - shipping and order total', async () => {

tests/shoppingCartTests/ShoppingCartSanityTest.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ test('test cart functionality behaves as expected', { tag: ['@SANITY'] }, async
1212
let jacketSize: string = 'L';
1313
let cartInitialPrice: string = '$42.00';
1414
let cartUpdatedPrice: string = '$84.00';
15-
let shippingTotalPrice: string = '';
1615
let itemInStock: string = 'In Stock';
1716
let updateQty: string = '2';
1817
let shippingMethod: string = 'Best Way';
1918
let orderTotal: string = 'Order Total';
2019
let updatedSize: string = 'XL'
20+
let updatedColor: string = 'Black'
2121
let purchaseConfirmation: string = 'Thank you for your purchase!';
2222
let expectedUserAddressDetails: string[] = ['John Doe', 'Jump Street 20', 'Miami, Florida 1000 P.O', 'United States', '55555'];
2323
await test.step('navigaet to mens category, hover over tops and choose hoodies and sweatshirts sub category', async () => {
@@ -38,7 +38,7 @@ test('test cart functionality behaves as expected', { tag: ['@SANITY'] }, async
3838
})
3939
await test.step('validate the item is in stock and change the quantity to 2 then click on update cart', async () => {
4040
await productPage.validateProductStockAvailability(itemInStock);
41-
await productPage.itemShoppingPage.chooseProductItem(jacketName, { modifyQuantity: true, quantity: updateQty, chooseSize: true, size: updatedSize });
41+
await productPage.itemShoppingPage.chooseProductItem(jacketName, { modifyQuantity: true, quantity: updateQty, chooseSize: true, size: updatedSize, chooseColor: true, color: updatedColor });
4242
await productPage.updateCart();
4343
})
4444
await test.step('validate price changed after adding another quantity then proceed to checkout', async () => {
@@ -50,7 +50,7 @@ test('test cart functionality behaves as expected', { tag: ['@SANITY'] }, async
5050
await checkoutShippingPage.clickNext();
5151
})
5252
await test.step('validate cart subtotal then place order and validate order was successfully made', async () => {
53-
await checkoutPaymentPage.validateOrderSummaryExpenses(orderTotal, '$114.00');
53+
await checkoutPaymentPage.validateOrderSummaryExpenses(orderTotal, cartUpdatedPrice);
5454
await checkoutPaymentPage.clickPlaceOrder();
5555
await checkoutPaymentPage.validatePurchaseConfirmationMessage(purchaseConfirmation);
5656
})

0 commit comments

Comments
 (0)