@@ -52,7 +52,6 @@ describe('WebDriver', function () {
52
52
beforeEach ( async ( ) => {
53
53
webApiTests . init ( { I : wd , siteUrl } )
54
54
this . wdBrowser = await wd . _before ( )
55
- this . wdBrowser . on ( 'dialog' , dialog => { } )
56
55
return this . wdBrowser
57
56
} )
58
57
@@ -509,85 +508,73 @@ describe('WebDriver', function () {
509
508
} )
510
509
511
510
describe ( '#waitNumberOfVisibleElements' , ( ) => {
512
- it ( 'should wait for a specified number of elements on the page' , ( ) => {
513
- return wd
514
- . amOnPage ( '/info' )
515
- . then ( ( ) => wd . waitNumberOfVisibleElements ( '//div[@id = "grab-multiple"]//a' , 3 ) )
516
- . then ( ( ) => wd . waitNumberOfVisibleElements ( '//div[@id = "grab-multiple"]//a' , 2 , 0.1 ) )
517
- . then ( ( ) => {
518
- throw Error ( 'It should never get this far' )
519
- } )
520
- . catch ( e => {
521
- e . message . should . include ( 'The number of elements (//div[@id = "grab-multiple"]//a) is not 2 after 0.1 sec' )
522
- } )
511
+ it ( 'should wait for a specified number of elements on the page' , async ( ) => {
512
+ try {
513
+ await wd . amOnPage ( '/info' )
514
+ await wd . waitNumberOfVisibleElements ( '//div[@id = "grab-multiple"]//a' , 3 )
515
+ await wd . waitNumberOfVisibleElements ( '//div[@id = "grab-multiple"]//a' , 2 , 0.1 )
516
+ throw new Error ( 'It should never get this far' )
517
+ } catch ( e ) {
518
+ e . message . should . include ( 'The number of elements (//div[@id = "grab-multiple"]//a) is not 2 after 0.1 sec' )
519
+ }
523
520
} )
524
521
525
- it ( 'should be no [object Object] in the error message' , ( ) => {
526
- return wd
527
- . amOnPage ( '/info' )
528
- . then ( ( ) => wd . waitNumberOfVisibleElements ( { css : '//div[@id = "grab-multiple"]//a' } , 3 ) )
529
- . then ( ( ) => {
530
- throw Error ( 'It should never get this far' )
531
- } )
532
- . catch ( e => {
533
- e . message . should . not . include ( '[object Object]' )
534
- } )
522
+ it ( 'should be no [object Object] in the error message' , async ( ) => {
523
+ try {
524
+ await wd . amOnPage ( '/info' )
525
+ await wd . waitNumberOfVisibleElements ( { css : '//div[@id = "grab-multiple"]//a' } , 3 )
526
+ throw new Error ( 'It should never get this far' )
527
+ } catch ( e ) {
528
+ e . message . should . not . include ( '[object Object]' )
529
+ }
535
530
} )
536
531
537
- it ( 'should wait for a specified number of elements on the page using a css selector' , ( ) => {
538
- return wd
539
- . amOnPage ( '/info' )
540
- . then ( ( ) => wd . waitNumberOfVisibleElements ( '#grab-multiple > a' , 3 ) )
541
- . then ( ( ) => wd . waitNumberOfVisibleElements ( '#grab-multiple > a' , 2 , 0.1 ) )
542
- . then ( ( ) => {
543
- throw Error ( 'It should never get this far' )
544
- } )
545
- . catch ( e => {
546
- e . message . should . include ( 'The number of elements (#grab-multiple > a) is not 2 after 0.1 sec' )
547
- } )
532
+ it ( 'should wait for a specified number of elements on the page using a css selector' , async ( ) => {
533
+ try {
534
+ await wd . amOnPage ( '/info' )
535
+ await wd . waitNumberOfVisibleElements ( '#grab-multiple > a' , 3 )
536
+ await wd . waitNumberOfVisibleElements ( '#grab-multiple > a' , 2 , 0.1 )
537
+ throw new Error ( 'It should never get this far' )
538
+ } catch ( e ) {
539
+ e . message . should . include ( 'The number of elements (#grab-multiple > a) is not 2 after 0.1 sec' )
540
+ }
548
541
} )
549
542
550
- it ( 'should wait for a specified number of elements which are not yet attached to the DOM' , ( ) => {
551
- return wd
552
- . amOnPage ( '/form/wait_num_elements' )
553
- . then ( ( ) => wd . waitNumberOfVisibleElements ( '.title' , 2 , 3 ) )
554
- . then ( ( ) => wd . see ( 'Hello' ) )
555
- . then ( ( ) => wd . see ( 'World' ) )
543
+ it ( 'should wait for a specified number of elements which are not yet attached to the DOM' , async ( ) => {
544
+ await wd . amOnPage ( '/form/wait_num_elements' )
545
+ await wd . waitNumberOfVisibleElements ( '.title' , 2 , 3 )
546
+ await wd . see ( 'Hello' )
547
+ await wd . see ( 'World' )
556
548
} )
557
549
} )
558
550
559
551
describe ( '#waitForVisible' , ( ) => {
560
- it ( 'should be no [object Object] in the error message' , ( ) => {
561
- return wd
562
- . amOnPage ( '/info' )
563
- . then ( ( ) => wd . waitForVisible ( '//div[@id = "grab-multiple"]//a' , 3 ) )
564
- . then ( ( ) => {
565
- throw Error ( 'It should never get this far' )
566
- } )
567
- . catch ( e => {
568
- e . message . should . not . include ( '[object Object]' )
569
- } )
552
+ it ( 'should be no [object Object] in the error message' , async ( ) => {
553
+ try {
554
+ await wd . amOnPage ( '/info' )
555
+ await wd . waitForVisible ( '//div[@id = "grab-multiple"]//a' , 3 )
556
+ throw new Error ( 'It should never get this far' )
557
+ } catch ( e ) {
558
+ e . message . should . not . include ( '[object Object]' )
559
+ }
570
560
} )
571
561
} )
572
562
573
563
describe ( '#waitForInvisible' , ( ) => {
574
- it ( 'should be no [object Object] in the error message' , ( ) => {
575
- return wd
576
- . amOnPage ( '/info' )
577
- . then ( ( ) => wd . waitForInvisible ( '//div[@id = "grab-multiple"]//a' , 3 ) )
578
- . then ( ( ) => {
579
- throw Error ( 'It should never get this far' )
580
- } )
581
- . catch ( e => {
582
- e . message . should . not . include ( '[object Object]' )
583
- } )
564
+ it ( 'should be no [object Object] in the error message' , async ( ) => {
565
+ try {
566
+ await wd . amOnPage ( '/info' )
567
+ await wd . waitForInvisible ( '//div[@id = "grab-multiple"]//a' , 3 )
568
+ throw new Error ( 'It should never get this far' )
569
+ } catch ( e ) {
570
+ e . message . should . not . include ( '[object Object]' )
571
+ }
584
572
} )
585
573
586
- it ( 'should wait for a specified element to be invisible' , ( ) => {
587
- return wd
588
- . amOnPage ( '/form/wait_invisible' )
589
- . then ( ( ) => wd . waitForInvisible ( '#step1' , 3 ) )
590
- . then ( ( ) => wd . dontSeeElement ( '#step1' ) )
574
+ it ( 'should wait for a specified element to be invisible' , async ( ) => {
575
+ await wd . amOnPage ( '/form/wait_invisible' )
576
+ await wd . waitForInvisible ( '#step1' , 3 )
577
+ await wd . dontSeeElement ( '#step1' )
591
578
} )
592
579
} )
593
580
@@ -625,117 +612,105 @@ describe('WebDriver', function () {
625
612
assert . equal ( numPagesAfter , 2 )
626
613
} )
627
614
628
- it ( 'should assert when there is no ability to switch to next tab' , ( ) => {
629
- return wd
630
- . amOnPage ( '/' )
631
- . then ( ( ) => wd . click ( 'More info' ) )
632
- . then ( ( ) => wd . wait ( 1 ) ) // Wait is required because the url is change by previous statement (maybe related to #914)
633
- . then ( ( ) => wd . switchToNextTab ( 2 ) )
634
- . then ( ( ) => assert . equal ( true , false , 'Throw an error if it gets this far (which it should not)!' ) )
635
- . catch ( e => {
636
- assert . equal ( e . message , 'There is no ability to switch to next tab with offset 2' )
637
- } )
615
+ it ( 'should assert when there is no ability to switch to next tab' , async ( ) => {
616
+ try {
617
+ await wd . amOnPage ( '/' )
618
+ await wd . click ( 'More info' )
619
+ await wd . wait ( 1 ) // Wait is required because the url is changed by the previous statement (maybe related to #914)
620
+ await wd . switchToNextTab ( 2 )
621
+ assert . equal ( true , false , 'Throw an error if it gets this far (which it should not)!' )
622
+ } catch ( e ) {
623
+ assert . equal ( e . message , 'There is no ability to switch to next tab with offset 2' )
624
+ }
638
625
} )
639
626
640
- it ( 'should close current tab' , ( ) => {
641
- return wd
642
- . amOnPage ( '/info' )
643
- . then ( ( ) => wd . click ( 'New tab' ) )
644
- . then ( ( ) => wd . switchToNextTab ( ) )
645
- . then ( ( ) => wd . seeInCurrentUrl ( '/login' ) )
646
- . then ( ( ) => wd . grabNumberOfOpenTabs ( ) )
647
- . then ( numPages => assert . equal ( numPages , 2 ) )
648
- . then ( ( ) => wd . closeCurrentTab ( ) )
649
- . then ( ( ) => wd . seeInCurrentUrl ( '/info' ) )
650
- . then ( ( ) => wd . grabNumberOfOpenTabs ( ) )
627
+ it ( 'should close current tab' , async ( ) => {
628
+ await wd . amOnPage ( '/info' )
629
+ await wd . click ( 'New tab' )
630
+ await wd . switchToNextTab ( )
631
+ await wd . seeInCurrentUrl ( '/login' )
632
+ const numPages = await wd . grabNumberOfOpenTabs ( )
633
+ assert . equal ( numPages , 2 )
634
+ await wd . closeCurrentTab ( )
635
+ await wd . seeInCurrentUrl ( '/info' )
636
+ await wd . grabNumberOfOpenTabs ( )
651
637
} )
652
638
653
- it ( 'should close other tabs' , ( ) => {
654
- return wd
655
- . amOnPage ( '/' )
656
- . then ( ( ) => wd . openNewTab ( ) )
657
- . then ( ( ) => wd . seeInCurrentUrl ( 'about:blank' ) )
658
- . then ( ( ) => wd . amOnPage ( '/info' ) )
659
- . then ( ( ) => wd . click ( 'New tab' ) )
660
- . then ( ( ) => wd . switchToNextTab ( ) )
661
- . then ( ( ) => wd . seeInCurrentUrl ( '/login' ) )
662
- . then ( ( ) => wd . closeOtherTabs ( ) )
663
- . then ( ( ) => wd . seeInCurrentUrl ( '/login' ) )
664
- . then ( ( ) => wd . grabNumberOfOpenTabs ( ) )
665
- } )
666
-
667
- it ( 'should open new tab' , ( ) => {
668
- return wd
669
- . amOnPage ( '/info' )
670
- . then ( ( ) => wd . openNewTab ( ) )
671
- . then ( ( ) => wd . waitInUrl ( 'about:blank' ) )
672
- . then ( ( ) => wd . grabNumberOfOpenTabs ( ) )
673
- . then ( numPages => assert . equal ( numPages , 2 ) )
639
+ it ( 'should close other tabs' , async ( ) => {
640
+ await wd . amOnPage ( '/' )
641
+ await wd . openNewTab ( )
642
+ await wd . seeInCurrentUrl ( 'about:blank' )
643
+ await wd . amOnPage ( '/info' )
644
+ await wd . click ( 'New tab' )
645
+ await wd . switchToNextTab ( )
646
+ await wd . seeInCurrentUrl ( '/login' )
647
+ await wd . closeOtherTabs ( )
648
+ await wd . seeInCurrentUrl ( '/login' )
649
+ await wd . grabNumberOfOpenTabs ( )
674
650
} )
675
651
676
- it ( 'should switch to previous tab' , ( ) => {
677
- return wd
678
- . amOnPage ( '/info' )
679
- . then ( ( ) => wd . openNewTab ( ) )
680
- . then ( ( ) => wd . waitInUrl ( 'about:blank' ) )
681
- . then ( ( ) => wd . switchToPreviousTab ( ) )
682
- . then ( ( ) => wd . waitInUrl ( '/info' ) )
652
+ it ( 'should open new tab' , async ( ) => {
653
+ await wd . amOnPage ( '/info' )
654
+ await wd . openNewTab ( )
655
+ await wd . waitInUrl ( 'about:blank' )
656
+ const numPages = await wd . grabNumberOfOpenTabs ( )
657
+ assert . equal ( numPages , 2 )
683
658
} )
684
659
685
- it ( 'should assert when there is no ability to switch to previous tab' , ( ) => {
686
- return wd
687
- . amOnPage ( '/info' )
688
- . then ( ( ) => wd . openNewTab ( ) )
689
- . then ( ( ) => wd . waitInUrl ( 'about:blank' ) )
690
- . then ( ( ) => wd . switchToPreviousTab ( 2 ) )
691
- . then ( ( ) => wd . waitInUrl ( '/info' ) )
692
- . catch ( e => {
693
- assert . equal ( e . message , 'There is no ability to switch to previous tab with offset 2' )
694
- } )
660
+ it ( 'should switch to previous tab' , async ( ) => {
661
+ await wd . amOnPage ( '/info' )
662
+ await wd . openNewTab ( )
663
+ await wd . waitInUrl ( 'about:blank' )
664
+ await wd . switchToPreviousTab ( )
665
+ await wd . waitInUrl ( '/info' )
666
+ } )
667
+
668
+ it ( 'should assert when there is no ability to switch to previous tab' , async ( ) => {
669
+ try {
670
+ await wd . amOnPage ( '/info' )
671
+ await wd . openNewTab ( )
672
+ await wd . waitInUrl ( 'about:blank' )
673
+ await wd . switchToPreviousTab ( 2 )
674
+ await wd . waitInUrl ( '/info' )
675
+ } catch ( e ) {
676
+ assert . equal ( e . message , 'There is no ability to switch to previous tab with offset 2' )
677
+ }
695
678
} )
696
679
} )
697
680
698
- // TO-DO: those tests are flaky so skipping them for now
699
681
describe ( 'popup : #acceptPopup, #seeInPopup, #cancelPopup' , async ( ) => {
700
682
it ( 'should accept popup window' , async ( ) => {
701
683
await wd . amOnPage ( '/form/popup' )
702
- await wd . waitForText ( 'Confirm' , 5 )
703
684
await wd . click ( 'Confirm' )
704
685
await wd . acceptPopup ( )
705
- await wd . waitForElement ( { css : '#result' } , 5 )
706
686
await wd . see ( 'Yes' , '#result' )
707
687
} )
708
688
709
689
it ( 'should cancel popup' , async ( ) => {
710
690
await wd . amOnPage ( '/form/popup' )
711
- await wd . waitForText ( 'Confirm' , 5 )
712
691
await wd . click ( 'Confirm' )
713
692
await wd . cancelPopup ( )
714
- await wd . waitForElement ( { css : '#result' } , 5 )
715
693
await wd . see ( 'No' , '#result' )
716
694
} )
717
695
718
- it ( 'should check text in popup' , ( ) => {
719
- return wd
720
- . amOnPage ( '/form/popup' )
721
- . then ( ( ) => wd . click ( 'Alert' ) )
722
- . then ( ( ) => wd . seeInPopup ( 'Really?' ) )
723
- . then ( ( ) => wd . cancelPopup ( ) )
696
+ it ( 'should check text in popup' , async ( ) => {
697
+ await wd . amOnPage ( '/form/popup' )
698
+ await wd . click ( 'Alert' )
699
+ await wd . seeInPopup ( 'Really?' )
700
+ await wd . cancelPopup ( )
724
701
} )
725
702
726
- it ( 'should grab text from popup' , ( ) => {
727
- return wd
728
- . amOnPage ( '/form/popup' )
729
- . then ( ( ) => wd . click ( 'Alert' ) )
730
- . then ( ( ) => wd . grabPopupText ( ) )
731
- . then ( text => assert . equal ( text , 'Really?' ) )
703
+ it ( 'should grab text from popup' , async ( ) => {
704
+ await wd . amOnPage ( '/form/popup' )
705
+ await wd . click ( 'Alert' )
706
+ const text = await wd . grabPopupText ( )
707
+ assert . equal ( text , 'Really?' )
732
708
} )
733
709
734
- it ( 'should return null if no popup is visible (do not throw an error)' , ( ) => {
735
- return wd
736
- . amOnPage ( '/form/popup' )
737
- . then ( ( ) => wd . grabPopupText ( ) )
738
- . then ( text => assert . equal ( text , null ) )
710
+ it ( 'should return null if no popup is visible (do not throw an error)' , async ( ) => {
711
+ await wd . amOnPage ( '/form/popup' )
712
+ const text = await wd . grabPopupText ( )
713
+ assert . equal ( text , null )
739
714
} )
740
715
} )
741
716
@@ -1296,7 +1271,6 @@ describe('WebDriver - Basic Authentication', () => {
1296
1271
1297
1272
afterEach ( ( ) => wd . _after ( ) )
1298
1273
1299
- // local run passed ✔ should be authenticated (443ms)
1300
1274
describe ( 'open page : #amOnPage' , ( ) => {
1301
1275
it ( 'should be authenticated' , async ( ) => {
1302
1276
await wd . amOnPage ( '/basic_auth' )
0 commit comments