@@ -54,6 +54,21 @@ module.exports = {
54
54
test . done ( ) ;
55
55
} )
56
56
} ,
57
+
58
+
59
+ 'to have attribute with implicit and custom waitFor [PASSED]' : function ( test ) {
60
+ Nocks . elementFound ( ) . attributeValue ( 'hp vasq' ) ;
61
+ this . client . api . globals . abortOnAssertionFailure = false ;
62
+ this . client . api . globals . waitForConditionTimeout = 65 ;
63
+
64
+ var expect = this . client . api . expect . element ( '#weblogin' ) . to . have . attribute ( 'class' ) . before ( 100 ) ;
65
+ this . client . on ( 'nightwatch:finished' , function ( results , errors ) {
66
+ test . equals ( expect . assertion . waitForMs , 100 ) ;
67
+ test . equals ( expect . assertion . passed , true ) ;
68
+ test . equals ( expect . assertion . message , 'Expected element <#weblogin> to have attribute "class" in 100ms - attribute was present in ' + expect . assertion . elapsedTime + 'ms' ) ;
69
+ test . done ( ) ;
70
+ } )
71
+ } ,
57
72
58
73
'to have attribute with waitFor [FAILED]' : function ( test ) {
59
74
this . client . api . globals . waitForConditionPollInterval = 50 ;
@@ -70,6 +85,21 @@ module.exports = {
70
85
} )
71
86
} ,
72
87
88
+ 'to have attribute with implicit and custom waitFor [FAILED]' : function ( test ) {
89
+ this . client . api . globals . waitForConditionPollInterval = 50 ;
90
+ Nocks . elementFound ( ) . attributeValue ( null ) ;
91
+ this . client . api . globals . waitForConditionTimeout = 65 ;
92
+
93
+ var expect = this . client . api . expect . element ( '#weblogin' ) . to . have . attribute ( 'class' ) . before ( 100 ) ;
94
+ this . client . on ( 'nightwatch:finished' , function ( results , errors ) {
95
+ test . equals ( expect . assertion . waitForMs , 100 ) ;
96
+ test . equals ( expect . assertion . passed , false ) ;
97
+ test . equals ( expect . assertion . abortOnFailure , true ) ;
98
+ test . equals ( expect . assertion . message , 'Expected element <#weblogin> to have attribute "class" in 100ms - attribute was not found' ) ;
99
+ test . done ( ) ;
100
+ } )
101
+ } ,
102
+
73
103
'to have attribute with message [PASSED]' : function ( test ) {
74
104
Nocks . elementFound ( ) . attributeValue ( 'hp vasq' ) ;
75
105
@@ -125,6 +155,7 @@ module.exports = {
125
155
this . client . on ( 'nightwatch:finished' , function ( results , errors ) {
126
156
test . equals ( expect . assertion . selector , '#weblogin' ) ;
127
157
test . equals ( expect . assertion . negate , true ) ;
158
+ test . equals ( expect . assertion . waitForMs , null ) ;
128
159
test . equals ( expect . assertion . passed , true ) ;
129
160
test . equals ( expect . assertion . expected , 'not found' ) ;
130
161
test . equals ( expect . assertion . actual , 'not found' ) ;
@@ -267,6 +298,23 @@ module.exports = {
267
298
} )
268
299
} ,
269
300
301
+ 'to have attribute equal with custom waitFor [PASSED]' : function ( test ) {
302
+ this . client . api . globals . waitForConditionPollInterval = 50 ;
303
+ this . client . api . globals . waitForConditionTimeout = 100 ;
304
+ Nocks . elementFound ( ) ;
305
+
306
+ var expect = this . client . api . expect . element ( '#weblogin' ) . to . have . attribute ( 'class' ) . equal ( 'hp vasq' ) . before ( 60 ) ;
307
+ Nocks . attributeValue ( null ) . attributeValue ( 'hp vasq' ) ;
308
+
309
+ this . client . on ( 'nightwatch:finished' , function ( results , errors ) {
310
+ test . equals ( expect . assertion . waitForMs , 60 ) ;
311
+ test . equals ( expect . assertion . passed , true ) ;
312
+ test . equals ( expect . assertion . retries , 1 ) ;
313
+ test . equals ( expect . assertion . message , 'Expected element <#weblogin> to have attribute "class" equal to: "hp vasq" in 60ms - condition was met in ' + expect . assertion . elapsedTime + 'ms' ) ;
314
+ test . done ( ) ;
315
+ } )
316
+ } ,
317
+
270
318
'to have attribute equal and waitFor [FAILED] - attribute not found' : function ( test ) {
271
319
this . client . api . globals . waitForConditionPollInterval = 50 ;
272
320
@@ -284,6 +332,23 @@ module.exports = {
284
332
} )
285
333
} ,
286
334
335
+ 'to have attribute equal and custom waitFor [FAILED] - attribute not found' : function ( test ) {
336
+ this . client . api . globals . waitForConditionPollInterval = 50 ;
337
+ this . client . api . globals . waitForConditionTimeout = 100 ;
338
+ Nocks . elementFound ( ) ;
339
+
340
+ var expect = this . client . api . expect . element ( '#weblogin' ) . to . have . attribute ( 'class' ) . equal ( 'hp vasq' ) . before ( 60 ) ;
341
+ Nocks . attributeValue ( null ) . attributeValue ( null ) ;
342
+
343
+ this . client . on ( 'nightwatch:finished' , function ( results , errors ) {
344
+ test . equals ( expect . assertion . waitForMs , 60 ) ;
345
+ test . equals ( expect . assertion . passed , false ) ;
346
+ test . ok ( expect . assertion . retries > 1 ) ;
347
+ test . equals ( expect . assertion . message , 'Expected element <#weblogin> to have attribute "class" equal to: "hp vasq" in 60ms - attribute was not found' ) ;
348
+ test . done ( ) ;
349
+ } )
350
+ } ,
351
+
287
352
'to have attribute equal and waitFor [FAILED] - attribute not equal' : function ( test ) {
288
353
this . client . api . globals . waitForConditionPollInterval = 10 ;
289
354
Nocks . elementFound ( ) . attributeValue ( 'xx' ) . attributeValue ( 'xx' ) ;
@@ -507,6 +572,21 @@ module.exports = {
507
572
} )
508
573
} ,
509
574
575
+ 'to have attribute with custom waitFor - element not found' : function ( test ) {
576
+ this . client . api . globals . waitForConditionPollInterval = 50 ;
577
+ this . client . api . globals . waitForConditionTimeout = 50 ;
578
+
579
+ Nocks . elementNotFound ( ) . elementNotFound ( ) . elementNotFound ( ) ;
580
+
581
+ var expect = this . client . api . expect . element ( '#weblogin' ) . to . have . attribute ( 'class' ) . before ( 100 ) ;
582
+ this . client . on ( 'nightwatch:finished' , function ( results , errors ) {
583
+ test . equal ( expect . assertion . waitForMs , 100 ) ;
584
+ test . equals ( expect . assertion . passed , false ) ;
585
+ test . equals ( expect . assertion . message , 'Expected element <#weblogin> to have attribute "class" in 100ms - element was not found' ) ;
586
+ test . done ( ) ;
587
+ } )
588
+ } ,
589
+
510
590
'to have attribute with waitFor - element found on retry' : function ( test ) {
511
591
this . client . api . globals . waitForConditionPollInterval = 50 ;
512
592
@@ -522,6 +602,22 @@ module.exports = {
522
602
} )
523
603
} ,
524
604
605
+ 'to have attribute with custom waitFor - element found on retry' : function ( test ) {
606
+ this . client . api . globals . waitForConditionPollInterval = 50 ;
607
+ this . client . api . globals . waitForConditionTimeout = 60 ;
608
+ Nocks . elementNotFound ( ) . elementFound ( ) . attributeValue ( 'hp vasq' ) ;
609
+
610
+ var expect = this . client . api . expect . element ( '#weblogin' ) . to . have . attribute ( 'class' ) . before ( 100 ) ;
611
+
612
+ this . client . on ( 'nightwatch:finished' , function ( results , errors ) {
613
+ test . equal ( expect . assertion . waitForMs , 100 ) ;
614
+ test . equals ( expect . assertion . passed , true ) ;
615
+ test . equals ( expect . assertion . message , 'Expected element <#weblogin> to have attribute "class" in 100ms - attribute was present in ' + expect . assertion . elapsedTime + 'ms' ) ;
616
+ test . done ( ) ;
617
+ } )
618
+ } ,
619
+
620
+
525
621
'to have attribute match - throws exception on invalid regex' : function ( test ) {
526
622
Nocks . elementFound ( ) . attributeValue ( 'xx' ) ;
527
623
0 commit comments