From 580d83ea10858e3185ecdd0342976badec40db5e Mon Sep 17 00:00:00 2001 From: SagarDurgade Date: Sat, 3 Aug 2024 01:12:00 +0530 Subject: [PATCH] test file updated --- test/assignment.test.ts | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 test/assignment.test.ts diff --git a/test/assignment.test.ts b/test/assignment.test.ts new file mode 100644 index 0000000000..830e1cfa04 --- /dev/null +++ b/test/assignment.test.ts @@ -0,0 +1,34 @@ +import { test, expect, chromium } from "@playwright/test"; +import { createPage } from "./amzon/app" + +test("test", async ({ page }) => { + // test.setTimeout(60000) + const pages = createPage(page) + + // Nevigare to amazon + pages.amazon.gotoUrl(testData.url) + + // The dropdown suggestions and validate all are related to searched product + pages.amazon.searchTextAndVerify(testData.search) + + // Search and select IPhone 13 128 GB + pages.amazon.searchAndSelect(testData.seatchText) + + // Navigate to next tab and click on Visit the Apple Store + const pagePromise = page.waitForEvent("popup") + await page.locator("//*[contains(text(),'Apple iPhone 13')]").first().click() + const newPage = await pagePromise + + await newPage.locator("//*[contains(text(),'Visit the Apple Store')]").click() + await newPage.getByRole("button", { name: "Apple Watch" }).click() + await newPage.getByRole("link", { name: "Apple Watch SE (GPS +" }).click() + await newPage.getByLabel("Quick look, Starlight Sport").first().click() + await expect(newPage.getByTestId("product-showcase-title")).toContainText(testData.verifyData) +}) + +const testData = { + url: "https://www.amazon.in/", + search: "iphone 13", + seatchText: "iphone 13 128GB", + verifyData: "[GPS + Cellular 40 mm]", +}