Skip to content

Commit 50ea021

Browse files
author
Sumit JAGOTA
committed
e2e test fixed
1 parent 5ffb1e6 commit 50ea021

File tree

3 files changed

+12
-6
lines changed

3 files changed

+12
-6
lines changed

base_fwk/common/CommonScenario.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { test, expect, Page, TestInfo } from "@playwright/test";
22
export class CommonScenario {
33
private myMap = new Map<string, string>();
4-
constructor(public page:Page, public testinfo: TestInfo) {
4+
constructor(public page: Page, public testinfo: TestInfo) {
55
}
66

77
async takeScreenshot(name: string) {

pageObjects/DashBoardPage/DashBoardPage.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,13 @@ export class DashboardPage extends CommonPage {
2222

2323
async navigateToOrders() {
2424
await this.page.locator(locators.orders).click();
25+
await this.page.waitForLoadState("networkidle");
2526
}
2627

2728

2829
async navigateToCart() {
2930
await this.page.locator(locators.cart).click();
3031
await this.page.waitForLoadState("networkidle");
32+
await this.page.waitForLoadState("domcontentloaded");
3133
}
3234
}

pageObjects/OrdersHistoryPage/OrdersHistoryPage.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Page } from "@playwright/test";
1+
import { expect, Page } from "@playwright/test";
22
import { CommonPage } from "../../base_fwk/common/CommonPage";
33
import { CommonScenario } from "../../base_fwk/common/CommonScenario";
44
import { locators } from "./OrdersHistoryPageLocators";
@@ -7,15 +7,19 @@ export class OrdersHistoryPage extends CommonPage {
77
constructor(public page: Page, public scenario: CommonScenario) {
88
super(page, scenario);
99
}
10+
1011
async searchOrderAndSelect() {
11-
const orderId = this.getValue("orderId");
12+
let orderFound = false;
13+
await this.page.waitForSelector('tbody');
1214
for (const row of await this.page.locator(locators.rows).all()) {
13-
if ((await row.locator("th").textContent())?.includes(orderId!)) {
14-
this.page.locator(locators.BTN_View).click();
15-
console.log("last element" + await row.locator("th").textContent())
15+
const matchrowOrderId = await row.locator("th").textContent();
16+
if (this.getValue("orderId")!.includes(matchrowOrderId!)) {
17+
await row.locator(locators.BTN_View).click();
18+
orderFound = true;
1619
break;
1720
}
1821
}
22+
expect(orderFound).toBeTruthy();
1923
this.takeScreenshot("Orders page");
2024
}
2125

0 commit comments

Comments
 (0)