@@ -64,6 +64,47 @@ export class Table {
6464
6565 return true ;
6666 }
67+
68+ async getHeaders ( ) {
69+ const headers = this . table . locator ( 'th.data-table__th' ) ;
70+ const headerCount = await headers . count ( ) ;
71+ const headerNames = [ ] ;
72+ for ( let i = 0 ; i < headerCount ; i ++ ) {
73+ headerNames . push ( await headers . nth ( i ) . innerText ( ) ) ;
74+ }
75+ return headerNames ;
76+ }
77+
78+ async getCellValueByHeader ( row : number , header : string ) {
79+ const headers = await this . getHeaders ( ) ;
80+ const colIndex = headers . indexOf ( header ) ;
81+ if ( colIndex === - 1 ) {
82+ throw new Error ( `Header "${ header } " not found` ) ;
83+ }
84+ const cell = this . table . locator (
85+ `tr.data-table__row:nth-child(${ row } ) td:nth-child(${ colIndex + 1 } )` ,
86+ ) ;
87+ return cell . innerText ( ) ;
88+ }
89+
90+ async waitForCellValueByHeader ( row : number , header : string , value : string ) {
91+ const headers = await this . getHeaders ( ) ;
92+ const colIndex = headers . indexOf ( header ) ;
93+ if ( colIndex === - 1 ) {
94+ throw new Error ( `Header "${ header } " not found` ) ;
95+ }
96+ const cell = this . table . locator (
97+ `tr.data-table__row:nth-child(${ row } ) td:nth-child(${ colIndex + 1 } )` ,
98+ ) ;
99+ await retryAction ( async ( ) => {
100+ const cellValue = ( await cell . innerText ( ) ) . trim ( ) ;
101+ if ( cellValue === value ) {
102+ return true ;
103+ }
104+ throw new Error ( `Cell value ${ cellValue } did not match expected ${ value } ` ) ;
105+ } ) ;
106+ return true ;
107+ }
67108}
68109
69110export enum QueriesSwitch {
0 commit comments