import { browser , by , element , ElementFinder } from 'protractor' ; export class InfiniteScrollPage { async getPage ( ) { await browser . get ( '#/infinite-scroll' ) ; } filter = element ( by . id ( 'filter' ) ) ; employees = element ( by . id ( 'employees' ) ) ; loadMoreButton = element ( by . id ( 'button1' ) ) ; loading = element ( by . id ( 'loading' ) ) ; loadOnScrollCheckbox = element ( by . id ( 'checkbox1' ) ) ; pageSize = element ( by . id ( 'numberPicker' ) ) ; confirmClassExists ( elem , soughtClass ) { return elem . getAttribute ( 'class' ) . then ( function ( classes ) { var allClasses = classes . split ( ' ' ) ; if ( allClasses . indexOf ( soughtClass ) > - 1 ) { return true ; } else { return false ; } } ) ; } confirmLoadOnScrollIsChecked ( ) { return this . confirmClassExists ( this . getCheckbox ( ) , 'ux-checkbox-checked' ) ; } confirmPageSizeButtonIsDisabled ( direction ) { if ( direction === 'down' ) { return this . confirmClassExists ( this . pageSize . $ ( 'div.number-picker-controls' ) . $ ( 'div.number-picker-control-down' ) , 'disabled' ) ; } else { return this . confirmClassExists ( this . pageSize . $ ( 'div.number-picker-controls' ) . $ ( 'div.number-picker-control-up' ) , 'disabled' ) ; } } confirmLoadMoreIsVisible ( ) { return this . loadMoreButton . isPresent ( ) ; } confirmValueIsInvalid ( ) { return this . confirmClassExists ( this . pageSize , 'has-error' ) ; } getEmployee ( index ) { return this . employees . $$ ( 'li.employee-item' ) . get ( index ) ; } getCheckbox ( ) { return this . loadOnScrollCheckbox . $ ( '.ux-checkbox' ) ; } getPageSize ( ) { return this . pageSize . $ ( 'input.form-control' ) ; } getEmployeeText ( index ) { return this . getEmployee ( index ) . $ ( 'div.employee-details' ) . $$ ( 'div' ) . first ( ) . $ ( 'span.employee-name' ) . getText ( ) ; } getDepartmentText ( index ) { return this . getEmployee ( index ) . $ ( 'div.employee-details' ) . $$ ( 'div' ) . first ( ) . $ ( 'span.employee-department' ) . getText ( ) ; } getEmailText ( index ) { return this . getEmployee ( index ) . $ ( 'div.employee-details' ) . $$ ( 'div' ) . last ( ) . $ ( 'span.employee-email' ) . getText ( ) ; } getEmployeeIDNumber ( index ) { return this . getEmployee ( index ) . $ ( 'div.employee-id' ) . getText ( ) ; } async clickOnLoadOnScroll ( ) { await this . getCheckbox ( ) . click ( ) ; } async clickOnPageSize ( ) { await this . getPageSize ( ) . click ( ) ; } async clickOnIncrementPageSize ( ) { await this . pageSize . $ ( 'div.number-picker-controls' ) . $ ( 'div.number-picker-control-up' ) . click ( ) ; } async clickOnDecrementPageSize ( ) { await this . pageSize . $ ( 'div.number-picker-controls' ) . $ ( 'div.number-picker-control-down' ) . click ( ) ; } getNumberOfEmployees ( ) { return this . employees . $$ ( 'li.employee-item' ) . count ( ) ; } async hoverOverLastEmployee ( ) { await browser . actions ( ) . mouseMove ( this . employees . $$ ( 'li.employee-item' ) . last ( ) ) . perform ( ) ; } }