31 lines
1.1 KiB
TypeScript
31 lines
1.1 KiB
TypeScript
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 there’s 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}`);
|
||
}
|
||
}
|
||
});
|