增加step描述,简化报告展示
This commit is contained in:
parent
799d6a5100
commit
4470b83c92
|
@ -1,4 +1,5 @@
|
||||||
import type { Page, Locator } from 'playwright-core';
|
import type { Page, Locator } from 'playwright-core';
|
||||||
|
import { test } from '@playwright/test'
|
||||||
|
|
||||||
export default class Table {
|
export default class Table {
|
||||||
readonly tableLocator: Locator
|
readonly tableLocator: Locator
|
||||||
|
@ -6,13 +7,16 @@ export default class Table {
|
||||||
this.page = page;
|
this.page = page;
|
||||||
this.tableLocator = this.page.locator('//div[contains(@class,"singleTable")]').filter({ hasText: `${this.tableUniqueText}` });
|
this.tableLocator = this.page.locator('//div[contains(@class,"singleTable")]').filter({ hasText: `${this.tableUniqueText}` });
|
||||||
}
|
}
|
||||||
|
|
||||||
private async getTableHeaders(): Promise<string[]> {
|
private async getTableHeaders(): Promise<string[]> {
|
||||||
await this.tableLocator.waitFor({ state: "visible" });
|
const headerTexts = await test.step('Query table headers and return a list', async () => {
|
||||||
const headers = await this.tableLocator.locator('thead tr th').all();
|
await this.tableLocator.waitFor({ state: "visible" });
|
||||||
const headerTexts = await Promise.all(headers.map(async (header) => {
|
const headers = await this.tableLocator.locator('thead tr th').all();
|
||||||
return await header.innerText();
|
const headerTexts = await Promise.all(headers.map(async (header) => {
|
||||||
}));
|
return await header.innerText();
|
||||||
|
}));
|
||||||
|
return headerTexts;
|
||||||
|
});
|
||||||
return headerTexts;
|
return headerTexts;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,7 +43,4 @@ export default class Table {
|
||||||
return rowLocator.locator(`td:nth-child(${col_index + 1})`);
|
return rowLocator.locator(`td:nth-child(${col_index + 1})`);
|
||||||
}
|
}
|
||||||
|
|
||||||
//生成正常表达式:判断元素text不等于""或者不等于"-"
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue