Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions tests/gearSection/hot_sellers_products_count.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { test, expect } from "@playwright/test";

test("Verify if 4 products are under Hot sellers category", async ({
page,
}) => {
await page.goto("https://magento.softwaretestingboard.com/gear.html");
const products = await page.locator(".product-image-photo").count();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is recommended to utilize Playwright's built-in methods for assertions

const products = await page.locator(".product-image-photo");
await expect(products).toHaveCount(4);

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perfect. Now how would you write this in just one line?

await expect(products).toBe(4);
Comment on lines +7 to +8
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const products = await page.locator(".product-image-photo").count();
await expect(products).toBe(4);
await expect(page.locator(".product-image-photo")).toHaveCount(4);

});