import { browser , by , element , ElementFinder } from 'protractor' ; export class NumberPickerPage { root = element ( by . id ( 'root' ) ) ; numberPicker1 = element ( by . id ( 'numberPicker1' ) ) ; numberPicker2 = element ( by . id ( 'numberPicker2' ) ) ; errorMessage1 = element ( by . id ( 'errorMessage1' ) ) ; errorMessage2 = element ( by . id ( 'errorMessage2' ) ) ; async getPage ( ) { await browser . get ( '#/number-picker' ) ; } async getNumberPickerMinimum ( numberPicker ) { return await numberPicker . getAttribute ( 'min' ) ; } async getNumberPickerMaximum ( numberPicker ) { return await numberPicker . getAttribute ( 'max' ) ; } async getNumberPickerStep ( numberPicker ) { return await numberPicker . getAttribute ( 'step' ) || '1' ; } async getNumberPickerValue ( numberPicker ) { return await numberPicker . $ ( 'input' ) . getAttribute ( 'value' ) ; } async confirmNumberPickerClassExists ( item , soughtClass ) { const classes = await item . getAttribute ( 'class' ) ; return classes . split ( ' ' ) . indexOf ( soughtClass ) > - 1 ; } async confirmUpDownControlIsDisabled ( numberPicker , direction ) { let arrow ; if ( direction === 'up' ) { arrow = numberPicker . $ ( 'div.number-picker-controls' ) . $ ( 'div.number-picker-control-up' ) ; } else { arrow = numberPicker . $ ( 'div.number-picker-controls' ) . $ ( 'div.number-picker-control-down' ) ; } return await this . confirmNumberPickerClassExists ( arrow , 'disabled' ) ; } async setNumberPickerValue ( numberPicker , value ) { await numberPicker . $ ( 'input' ) . clear ( ) ; await numberPicker . $ ( 'input' ) . sendKeys ( value ) ; } async incrementNumberPickerValue ( numberPicker ) { await numberPicker . $ ( 'div.number-picker-controls' ) . $ ( 'div.number-picker-control-up' ) . click ( ) ; } async decrementNumberPickerValue ( numberPicker ) { await numberPicker . $ ( 'div.number-picker-controls' ) . $ ( 'div.number-picker-control-down' ) . click ( ) ; } }