From 4470b83c921c219a8e356994f4db7e5ff8efd8f5 Mon Sep 17 00:00:00 2001 From: "zhiyong.yue" Date: Tue, 23 May 2023 17:22:37 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0step=E6=8F=8F=E8=BF=B0,?= =?UTF-8?q?=E7=AE=80=E5=8C=96=E6=8A=A5=E5=91=8A=E5=B1=95=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- page-object-model/Table.ts | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/page-object-model/Table.ts b/page-object-model/Table.ts index e22822f..772b3f8 100644 --- a/page-object-model/Table.ts +++ b/page-object-model/Table.ts @@ -1,4 +1,5 @@ import type { Page, Locator } from 'playwright-core'; +import { test } from '@playwright/test' export default class Table { readonly tableLocator: Locator @@ -6,13 +7,16 @@ export default class Table { this.page = page; this.tableLocator = this.page.locator('//div[contains(@class,"singleTable")]').filter({ hasText: `${this.tableUniqueText}` }); } - + private async getTableHeaders(): Promise { - await this.tableLocator.waitFor({ state: "visible" }); - const headers = await this.tableLocator.locator('thead tr th').all(); - const headerTexts = await Promise.all(headers.map(async (header) => { - return await header.innerText(); - })); + const headerTexts = await test.step('Query table headers and return a list', async () => { + await this.tableLocator.waitFor({ state: "visible" }); + const headers = await this.tableLocator.locator('thead tr th').all(); + const headerTexts = await Promise.all(headers.map(async (header) => { + return await header.innerText(); + })); + return headerTexts; + }); return headerTexts; } @@ -39,7 +43,4 @@ export default class Table { return rowLocator.locator(`td:nth-child(${col_index + 1})`); } - //生成正常表达式:判断元素text不等于""或者不等于"-" - - } \ No newline at end of file