增加step描述,简化报告展示

This commit is contained in:
zhiyong.yue 2023-05-23 17:22:37 +08:00
parent 799d6a5100
commit 4470b83c92
1 changed files with 10 additions and 9 deletions

View File

@ -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<string[]> {
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不等于""或者不等于"-"
}