We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 28ac452 commit 120233aCopy full SHA for 120233a
1 file changed
webui/e2e/helpers/table.ts
@@ -0,0 +1,16 @@
1
+import { Locator } from "@playwright/test";
2
+
3
+export async function getCellByColumnName(table: Locator, columnName: string, row?: Locator | undefined): Promise<Locator> {
4
+ const headerIndex = await table.getByRole('columnheader', { name: columnName, exact: true})
5
+ .evaluate(header => {
6
+ const headers = Array.from(header.closest('tr').querySelectorAll('th'));
7
+ // Return 1-based index for nth-child CSS selector
8
+ return headers.indexOf(header as HTMLTableCellElement) + 1;
9
+ });
10
11
+ if (!row) {
12
+ row = table.locator('tbody tr')
13
+ }
14
15
+ return row.locator(`td:nth-child(${headerIndex})`);
16
+}
0 commit comments