import { $ , browser , ElementFinder , Key } from 'protractor' ; export class TabbableListTestPageComponent { searchInput = $ ( 'input' ) ; wrapButton = $ ( '#wrap-button' ) ; boundaryButton = $ ( '#boundary-button' ) ; focusOnShowButton = $ ( '#focus-on-show-button' ) ; async getPage ( ) { await browser . get ( '#/tabbable-list/simple-list' ) ; } async getTableRows ( ) { const tbody = $ ( 'tbody' ) ; return await tbody . $$ ( 'tr' ) ; } async getTableRow ( index ) { const rows = await this . getTableRows ( ) ; return rows [ index ] ; } async getTabIndex ( index ) { const row = await this . getTableRow ( index ) ; return row . getAttribute ( 'tabindex' ) ; } async getFocused ( index ) { const row = await this . getTableRow ( index ) ; const classes = await row . getAttribute ( 'class' ) ; return classes . split ( ' ' ) . indexOf ( 'ux-focus-indicator-active' ) !== - 1 ; } async clickOnRow ( index ) { const row = await this . getTableRow ( index ) ; return row . click ( ) ; } async moveFocusDown ( ) { return browser . actions ( ) . sendKeys ( Key . ARROW_DOWN ) . perform ( ) ; } async moveFocusUp ( ) { return browser . actions ( ) . sendKeys ( Key . ARROW_UP ) . perform ( ) ; } async moveFocusHome ( ) { return browser . actions ( ) . sendKeys ( Key . HOME ) . perform ( ) ; } async moveFocusEnd ( ) { return browser . actions ( ) . sendKeys ( Key . END ) . perform ( ) ; } async toggleWrap ( ) { await this . wrapButton . click ( ) ; } async toggleBoundaryKeys ( ) { await this . boundaryButton . click ( ) ; } async toggleFocusOnShow ( ) { await this . focusOnShowButton . click ( ) ; } async search ( query ) { await this . searchInput . click ( ) ; await this . searchInput . sendKeys ( query ) ; } async clearSearch ( ) { const value = await this . searchInput . getAttribute ( 'value' ) ; for ( let idx = 0 ; idx < value . length ; idx ++ ) { await this . searchInput . sendKeys ( Key . BACK_SPACE ) ; } } }