@@ -11,6 +11,9 @@ export class TradeTradePage{
1111 readonly buyBtn : Locator
1212 readonly confirmBtn : Locator
1313 readonly orderedPopup : Locator
14+ readonly orderedCancelledPopup : Locator
15+ readonly cancelBtn : Locator
16+ readonly cancelAllBtn : Locator
1417
1518 constructor ( page : Page ) {
1619 this . page = page ;
@@ -24,9 +27,43 @@ export class TradeTradePage{
2427 this . buyBtn = this . page . getByRole ( 'button' , { name : 'Buy SWTH' , exact : true } )
2528 this . confirmBtn = this . page . getByRole ( 'button' , { name : 'Confirm' } )
2629 this . orderedPopup = this . page . getByText ( 'Order Placed' )
30+ this . orderedCancelledPopup = this . page . getByText ( 'Order Cancelled' )
31+ this . cancelBtn = this . page . getByRole ( 'button' , { name : 'Cancel' , exact : true } )
32+ this . cancelAllBtn = this . page . getByRole ( 'columnheader' , { name : 'Cancel All' } )
2733 }
2834
2935 async goToTradePage ( ) {
3036 await this . page . goto ( 'https://beta-app.dem.exchange/trade' ) ;
3137 }
38+
39+ async verifyTableData ( expectedData : Array < { [ key : string ] : string } > ) {
40+ const table = this . page . locator ( '//table[thead//th[contains(text(), "Date")]]' ) ;
41+ await expect ( table ) . toBeVisible ( ) ;
42+
43+ const headers = await table . locator ( 'thead tr th' ) . allInnerTexts ( ) ;
44+ console . log ( 'Column headers:' , headers ) ;
45+
46+ const columnIndexes : { [ key : string ] : number } = { } ;
47+ headers . forEach ( ( header , index ) => {
48+ columnIndexes [ header . trim ( ) ] = index + 1 ;
49+ } ) ;
50+ console . log ( 'Column Index:' , columnIndexes )
51+
52+ for ( let rowIndex = 0 ; rowIndex < expectedData . length ; rowIndex ++ ) {
53+ const row = table . locator ( `tbody tr:nth-child(${ rowIndex + 1 } )` ) ;
54+
55+ for ( const [ columnName , expectedValue ] of Object . entries ( expectedData [ rowIndex ] ) ) {
56+ if ( columnIndexes [ columnName ] !== undefined ) {
57+ const columnIndex = columnIndexes [ columnName ] ;
58+ const cellLocator = row . locator ( `td:nth-child(${ columnIndex } )` ) ;
59+
60+ await expect ( cellLocator ) . toHaveText ( expectedValue ) ;
61+ console . log ( `Row ${ rowIndex + 1 } , column "${ columnName } " verified: "${ expectedValue } "` ) ;
62+ } else {
63+ console . warn ( `Column "${ columnName } " not found!` ) ;
64+ }
65+ }
66+ }
67+ }
68+
3269}
0 commit comments