import { $ , browser , ElementFinder } from 'protractor' ; export class ColumnResizingPage { standardTable = $ ( '#standard-table' ) ; fixedTable = $ ( '#fixed-table' ) ; updateLayoutBtn = $ ( '#update-layout-btn' ) ; async getPage ( ) { await browser . driver . manage ( ) . window ( ) . setSize ( 1200 , 900 ) ; await browser . get ( '#/column-resizing' ) ; } async getColumnHeaders ( table ) { return table . $$ ( 'th' ) ; } async getColumnHeaderWidth ( table , index ) { const columns = await this . getColumnHeaders ( table ) ; return ( await columns [ index ] . getSize ( ) ) . width ; } async scrollTableToBottom ( table ) { const element = await table . $ ( 'tbody' ) ; await browser . executeScript ( 'arguments[0].scrollTop = arguments[0].scrollHeight' , await element . getWebElement ( ) ) ; } async getNumberOfRows ( table ) { return await table . $ ( 'tbody' ) . $$ ( 'tr' ) . count ( ) ; } async getRow ( table , index ) { const body = await table . $ ( 'tbody' ) ; return await body . $$ ( 'tr' ) . get ( index ) ; } async getColumnWidth ( table , rowIndex , columnIndex ) { const row = await this . getRow ( table , rowIndex ) ; const column = await row . $$ ( 'td' ) . get ( columnIndex ) ; const { width } = await column . getSize ( ) ; return width ; } async updateLayout ( ) { await this . updateLayoutBtn . click ( ) ; } async resizeColumn ( table , columnIndex , amount ) { const columns = await this . getColumnHeaders ( table ) ; const column = columns [ columnIndex ] ; const handle = await column . $ ( '.ux-resizable-table-column-handle' ) ; await browser . actions ( ) . mouseDown ( handle ) . mouseMove ( { x : amount , y : 0 } ) . mouseUp ( ) . perform ( ) ; } }