dailykart-testing/tests/new-products-order-button.spec.ts

31 lines
1.1 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { test, expect } from '@playwright/test';
test('#7 Each New Product should have an Order button', async ({ page }) => {
await page.goto('https://uat.dailykart.net');
// Scroll into view to make sure lazy-loaded elements appear
const newProductsSection = page.locator('text=New Products');
await newProductsSection.scrollIntoViewIfNeeded();
const productCards = await page.locator('div.product__box').all();
console.log(`🧪 Found ${productCards.length} new product cards`);
for (let i = 0; i < productCards.length; i++) {
const card = productCards[i];
// Check if theres any clickable ordering element
const orderElement = card.locator('a[href="#modalAddCart"], button', {
hasText: /order/i
});
// Fallback: check for cart icon
const cartIcon = card.locator('i.icon-shopping-cart');
if (await orderElement.count() > 0 || await cartIcon.count() > 0) {
console.log(` Order element found in card #${i + 1}`);
} else {
throw new Error(` No order/cart option in product card #${i + 1}`);
}
}
});