1- let cases = [
2- { 'username' : 'locked_user' , 'password' : 'testingisfun99' , 'error' : 'Your account has been locked.' } ,
3- { 'username' : 'fav_user' , 'password' : 'wrongpass' , 'error' : 'Invalid Password' } ,
4- { 'username' : 'helloworld' , 'password' : 'testingisfun99' , 'error' : 'Invalid Username' }
5- ]
6-
1+ var fs = require ( 'fs' ) ;
72describe ( 'StackDemo login' , ( ) => {
83
94 beforeEach ( 'Open StackDemo' , ( ) => {
@@ -13,14 +8,22 @@ describe('StackDemo login', () => {
138 afterEach ( 'clear sessionstorage' , ( ) => {
149 browser . execute ( ( ) => sessionStorage . clear ( ) )
1510 } )
16- cases . forEach ( ( { username, password, error } ) => {
17- it ( `should return '${ error } ' for account with username '${ username } '` , function ( ) {
18- $ ( '#signin' ) . click ( ) ;
19- $ ( '#username input' ) . setValue ( username + '\n' ) ;
20- $ ( '#password input' ) . setValue ( password + '\n' ) ;
21- $ ( '#login-btn' ) . click ( ) ;
2211
23- expect ( $ ( '.api-error' ) ) . toHaveText ( error ) ;
24- } )
12+ it ( 'login should be successful' , function ( ) {
13+ describe ( 'login should be successful for all data set' , function ( ) {
14+ testData . forEach ( function ( val , index ) {
15+ it ( `login sholud be successful for account with username '${ val . split ( ',' ) [ 0 ] } '` , function ( ) {
16+ console . log ( "login sholud be successful for account with username " + val . split ( ',' ) [ 0 ] )
17+ $ ( '#signin' ) . click ( ) ;
18+ $ ( '#username input' ) . setValue ( val . split ( ',' ) [ 0 ] + '\n' ) ;
19+ $ ( '#password input' ) . setValue ( val . split ( ',' ) [ 1 ] + '\n' ) ;
20+ $ ( '#login-btn' ) . click ( ) ;
21+
22+ expect ( $ ( '.username' ) ) . toHaveText ( val . split ( ',' ) [ 0 ] ) ;
23+
24+ $ ( '#logout' ) . click ( ) ;
25+ } ) ;
26+ } ) ;
27+ } ) ;
2528 } ) ;
2629} )
0 commit comments