var tp = require ( './lforms_testpage.po.js' ) ; describe ( 'keyboard navigation' , function ( ) { it ( 'should have one add button in the horizontal table when the form loads' , function ( ) { tp . openUSSGFHTHorizontal ( ) ; expect ( element . all ( by . css ( '.lf-float-button' ) ) . get ( 2 ) . isPresent ( ) ) . toBe ( true ) ; expect ( element . all ( by . css ( '.lf-float-button' ) ) . get ( 2 ) . getText ( ) ) . toBe ( '+ Add another "This family member\'s history of disease"' ) ; } ) ; it ( 'should move around the lists and the tables by using ctrl-arrow keys' , function ( ) { var eleName = element ( by . id ( '/54126-8/54125-0/1/1' ) ) ; var eleGender = element ( by . id ( '/54126-8/54131-8/1/1' ) ) ; var eleDOB = element ( by . id ( '/54126-8/21112-8/1/1' ) ) ; var eleEthnicity = element ( by . id ( '/54114-4/54120-1/1/1' ) ) ; var eleRace = element ( by . id ( '/54114-4/54119-3R/1/1' ) ) ; var eleDisease1 = element ( by . id ( '/54114-4/54117-7/54116-9/1/1/1' ) ) ; var eleAgeAtD1 = element ( by . id ( '/54114-4/54117-7/54115-1/1/1/1' ) ) ; var eleBMI1 = element ( by . id ( '/54114-4/54117-7/39156-5/1/1/1' ) ) ; eleName . click ( ) ; eleName . sendKeys ( protractor . Key . CONTROL , protractor . Key . ARROW_DOWN ) ; expect ( browser . driver . switchTo ( ) . activeElement ( ) . getAttribute ( 'id' ) ) . toEqual ( eleGender . getAttribute ( 'id' ) ) ; eleGender . sendKeys ( protractor . Key . CONTROL , protractor . Key . ARROW_DOWN ) ; expect ( browser . driver . switchTo ( ) . activeElement ( ) . getAttribute ( 'id' ) ) . toEqual ( eleDOB . getAttribute ( 'id' ) ) ; eleDOB . sendKeys ( protractor . Key . CONTROL , protractor . Key . ARROW_UP ) ; expect ( browser . driver . switchTo ( ) . activeElement ( ) . getAttribute ( 'id' ) ) . toEqual ( eleGender . getAttribute ( 'id' ) ) ; eleGender . sendKeys ( protractor . Key . CONTROL , protractor . Key . ARROW_LEFT ) ; expect ( browser . driver . switchTo ( ) . activeElement ( ) . getAttribute ( 'id' ) ) . toEqual ( eleName . getAttribute ( 'id' ) ) ; eleName . sendKeys ( protractor . Key . CONTROL , protractor . Key . ARROW_LEFT ) ; expect ( browser . driver . switchTo ( ) . activeElement ( ) . getAttribute ( 'id' ) ) . toEqual ( eleName . getAttribute ( 'id' ) ) ; eleName . sendKeys ( protractor . Key . CONTROL , protractor . Key . ARROW_UP ) ; expect ( browser . driver . switchTo ( ) . activeElement ( ) . getAttribute ( 'id' ) ) . toEqual ( eleName . getAttribute ( 'id' ) ) ; eleName . sendKeys ( protractor . Key . CONTROL , protractor . Key . ARROW_RIGHT ) ; expect ( browser . driver . switchTo ( ) . activeElement ( ) . getAttribute ( 'id' ) ) . toEqual ( eleGender . getAttribute ( 'id' ) ) ; element . all ( by . css ( '.lf-float-button' ) ) . get ( 2 ) . click ( ) ; expect ( element . all ( by . css ( '.lf-float-button' ) ) . get ( 2 ) . getText ( ) ) . toBe ( '-' ) ; expect ( element . all ( by . css ( '.lf-float-button' ) ) . get ( 3 ) . getText ( ) ) . toBe ( '-' ) ; expect ( element . all ( by . css ( '.lf-float-button' ) ) . get ( 4 ) . getText ( ) ) . toBe ( '+ Add another "This family member\'s history of disease"' ) ; var eleDisease2 = element ( by . id ( '/54114-4/54117-7/54116-9/1/2/1' ) ) ; var eleAgeAtD2 = element ( by . id ( '/54114-4/54117-7/54115-1/1/2/1' ) ) ; var eleBMI2 = element ( by . id ( '/54114-4/54117-7/39156-5/1/2/1' ) ) ; eleEthnicity . click ( ) ; eleEthnicity . sendKeys ( protractor . Key . CONTROL , protractor . Key . ARROW_DOWN ) ; expect ( browser . driver . switchTo ( ) . activeElement ( ) . getAttribute ( 'id' ) ) . toEqual ( eleDisease1 . getAttribute ( 'id' ) ) ; eleDisease1 . sendKeys ( protractor . Key . CONTROL , protractor . Key . ARROW_UP ) ; expect ( browser . driver . switchTo ( ) . activeElement ( ) . getAttribute ( 'id' ) ) . toEqual ( eleEthnicity . getAttribute ( 'id' ) ) ; eleEthnicity . sendKeys ( protractor . Key . CONTROL , protractor . Key . ARROW_RIGHT ) ; expect ( browser . driver . switchTo ( ) . activeElement ( ) . getAttribute ( 'id' ) ) . toEqual ( eleDisease1 . getAttribute ( 'id' ) ) ; eleDisease1 . sendKeys ( protractor . Key . CONTROL , protractor . Key . ARROW_LEFT ) ; expect ( browser . driver . switchTo ( ) . activeElement ( ) . getAttribute ( 'id' ) ) . toEqual ( eleEthnicity . getAttribute ( 'id' ) ) ; eleEthnicity . sendKeys ( protractor . Key . CONTROL , protractor . Key . ARROW_DOWN ) ; expect ( browser . driver . switchTo ( ) . activeElement ( ) . getAttribute ( 'id' ) ) . toEqual ( eleDisease1 . getAttribute ( 'id' ) ) ; eleDisease1 . sendKeys ( protractor . Key . CONTROL , protractor . Key . ARROW_DOWN ) ; expect ( browser . driver . switchTo ( ) . activeElement ( ) . getAttribute ( 'id' ) ) . toEqual ( eleDisease2 . getAttribute ( 'id' ) ) ; eleDisease2 . sendKeys ( protractor . Key . CONTROL , protractor . Key . ARROW_RIGHT ) ; expect ( browser . driver . switchTo ( ) . activeElement ( ) . getAttribute ( 'id' ) ) . toEqual ( eleAgeAtD2 . getAttribute ( 'id' ) ) ; eleAgeAtD2 . sendKeys ( protractor . Key . CONTROL , protractor . Key . ARROW_UP ) ; expect ( browser . driver . switchTo ( ) . activeElement ( ) . getAttribute ( 'id' ) ) . toEqual ( eleAgeAtD1 . getAttribute ( 'id' ) ) ; eleAgeAtD1 . sendKeys ( protractor . Key . CONTROL , protractor . Key . ARROW_LEFT ) ; expect ( browser . driver . switchTo ( ) . activeElement ( ) . getAttribute ( 'id' ) ) . toEqual ( eleDisease1 . getAttribute ( 'id' ) ) ; eleDisease1 . sendKeys ( protractor . Key . CONTROL , protractor . Key . ARROW_DOWN ) ; expect ( browser . driver . switchTo ( ) . activeElement ( ) . getAttribute ( 'id' ) ) . toEqual ( eleDisease2 . getAttribute ( 'id' ) ) ; eleDisease2 . sendKeys ( protractor . Key . CONTROL , protractor . Key . ARROW_DOWN ) ; expect ( browser . driver . switchTo ( ) . activeElement ( ) . getAttribute ( 'id' ) ) . toEqual ( eleRace . getAttribute ( 'id' ) ) ; eleRace . sendKeys ( protractor . Key . CONTROL , protractor . Key . ARROW_LEFT ) ; expect ( browser . driver . switchTo ( ) . activeElement ( ) . getAttribute ( 'id' ) ) . toEqual ( eleBMI2 . getAttribute ( 'id' ) ) ; eleBMI2 . sendKeys ( protractor . Key . CONTROL , protractor . Key . ARROW_RIGHT ) ; expect ( browser . driver . switchTo ( ) . activeElement ( ) . getAttribute ( 'id' ) ) . toEqual ( eleRace . getAttribute ( 'id' ) ) ; eleRace . sendKeys ( protractor . Key . CONTROL , protractor . Key . ARROW_LEFT ) ; expect ( browser . driver . switchTo ( ) . activeElement ( ) . getAttribute ( 'id' ) ) . toEqual ( eleBMI2 . getAttribute ( 'id' ) ) ; eleBMI2 . sendKeys ( protractor . Key . CONTROL , protractor . Key . ARROW_UP ) ; expect ( browser . driver . switchTo ( ) . activeElement ( ) . getAttribute ( 'id' ) ) . toEqual ( eleBMI1 . getAttribute ( 'id' ) ) ; eleBMI1 . sendKeys ( protractor . Key . CONTROL , protractor . Key . ARROW_RIGHT ) ; expect ( browser . driver . switchTo ( ) . activeElement ( ) . getAttribute ( 'id' ) ) . toEqual ( eleDisease2 . getAttribute ( 'id' ) ) ; eleDisease2 . sendKeys ( protractor . Key . CONTROL , protractor . Key . ARROW_LEFT ) ; expect ( browser . driver . switchTo ( ) . activeElement ( ) . getAttribute ( 'id' ) ) . toEqual ( eleBMI1 . getAttribute ( 'id' ) ) ; eleBMI1 . sendKeys ( protractor . Key . CONTROL , protractor . Key . ARROW_UP ) ; expect ( browser . driver . switchTo ( ) . activeElement ( ) . getAttribute ( 'id' ) ) . toEqual ( eleEthnicity . getAttribute ( 'id' ) ) ; } ) ; } ) ;