@@ -623,14 +623,22 @@ class CalculatorUITests: XCTestCase {
623
623
XCTAssertTrue ( app. staticTexts [ " 39 " ] . exists)
624
624
}
625
625
626
- func showCalculator( ) {
626
+ func showCalculator( navBarTitle : String = " Calculator.GraphingView " ) {
627
627
// Don't know if this is the best way to make the calculator visible ...
628
- if XCUIApplication ( ) . navigationBars [ " Calculator.GraphingView " ] . exists {
629
- XCUIApplication ( ) . navigationBars [ " Calculator.GraphingView " ] . buttons [ " Calculator " ] . tap ( )
630
- } else {
631
- if !XCUIApplication( ) . navigationBars. element. isHittable {
628
+ if XCUIApplication ( ) . buttons [ " Graph " ] . exists {
629
+ if !XCUIApplication( ) . buttons [ " Graph " ] . isHittable {
632
630
XCUIApplication ( ) . children ( matching: . window) . element ( boundBy: 0 ) . children ( matching: . other) . element. children ( matching: . other) . element ( boundBy: 1 ) . children ( matching: . other) . element. swipeRight ( )
633
631
}
632
+ } else {
633
+ if XCUIApplication ( ) . navigationBars [ navBarTitle] . exists {
634
+ if XCUIApplication ( ) . navigationBars [ navBarTitle] . buttons [ " Calculator " ] . exists {
635
+ XCUIApplication ( ) . navigationBars [ navBarTitle] . buttons [ " Calculator " ] . tap ( )
636
+ }
637
+ } else {
638
+ if !XCUIApplication( ) . navigationBars. element. isHittable {
639
+ XCUIApplication ( ) . children ( matching: . window) . element ( boundBy: 0 ) . children ( matching: . other) . element. children ( matching: . other) . element ( boundBy: 1 ) . children ( matching: . other) . element. swipeRight ( )
640
+ }
641
+ }
634
642
}
635
643
}
636
644
@@ -640,15 +648,15 @@ class CalculatorUITests: XCTestCase {
640
648
app. buttons [ " M " ] . tap ( )
641
649
app. buttons [ " cos " ] . tap ( )
642
650
app. buttons [ " Graph " ] . tap ( )
643
- showCalculator ( )
651
+ showCalculator ( navBarTitle : " cos(M) " )
644
652
XCTAssert ( app. staticTexts [ " cos(M) = " ] . exists)
645
653
XCTAssert ( app. staticTexts [ " 1 " ] . exists)
646
654
XCTAssert ( app. staticTexts [ " " ] . exists)
647
655
648
656
app. buttons [ " M " ] . tap ( )
649
657
app. buttons [ " √ " ] . tap ( )
650
658
app. buttons [ " Graph " ] . tap ( )
651
- showCalculator ( )
659
+ showCalculator ( navBarTitle : " √(M) " )
652
660
XCTAssert ( app. staticTexts [ " √(M) = " ] . exists)
653
661
XCTAssert ( app. staticTexts [ " 0 " ] . exists)
654
662
XCTAssert ( app. staticTexts [ " " ] . exists)
@@ -660,17 +668,39 @@ class CalculatorUITests: XCTestCase {
660
668
XCTAssert ( app. staticTexts [ " 3 " ] . exists)
661
669
XCTAssert ( app. staticTexts [ " 9 " ] . exists)
662
670
app. buttons [ " Graph " ] . tap ( )
663
- showCalculator ( )
671
+ showCalculator ( navBarTitle : " √(M) " )
664
672
XCTAssert ( app. staticTexts [ " √(M) = " ] . exists)
665
673
XCTAssert ( app. staticTexts [ " 3 " ] . exists)
666
674
XCTAssert ( app. staticTexts [ " 9 " ] . exists)
667
675
668
676
app. buttons [ " M " ] . tap ( )
669
677
app. buttons [ " tan " ] . tap ( )
670
678
app. buttons [ " Graph " ] . tap ( )
671
- showCalculator ( )
679
+ showCalculator ( navBarTitle : " tan(M) " )
672
680
XCTAssert ( app. staticTexts [ " tan(M) = " ] . exists)
673
681
XCTAssert ( app. staticTexts [ " -0.452316 " ] . exists)
674
682
XCTAssert ( app. staticTexts [ " 9 " ] . exists)
675
683
}
684
+
685
+ func testGraphTitleAssignment3Task8( ) {
686
+ let app = XCUIApplication ( )
687
+
688
+ app. buttons [ " M " ] . tap ( )
689
+ app. buttons [ " cos " ] . tap ( )
690
+ app. buttons [ " Graph " ] . tap ( )
691
+ XCTAssert ( app. staticTexts [ " cos(M) " ] . exists)
692
+ showCalculator ( navBarTitle: " cos(M) " )
693
+ XCTAssert ( app. staticTexts [ " cos(M) = " ] . exists)
694
+ XCTAssert ( app. staticTexts [ " 1 " ] . exists)
695
+ XCTAssert ( app. staticTexts [ " " ] . exists)
696
+
697
+ app. buttons [ " M " ] . tap ( )
698
+ app. buttons [ " √ " ] . tap ( )
699
+ app. buttons [ " Graph " ] . tap ( )
700
+ XCTAssert ( app. staticTexts [ " √(M) " ] . exists)
701
+ showCalculator ( navBarTitle: " √(M) " )
702
+ XCTAssert ( app. staticTexts [ " √(M) = " ] . exists)
703
+ XCTAssert ( app. staticTexts [ " 0 " ] . exists)
704
+ XCTAssert ( app. staticTexts [ " " ] . exists)
705
+ }
676
706
}
0 commit comments