diff --git a/CHANGELOG.md b/CHANGELOG.md
index eb9b9789..ed6ea246 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -9,6 +9,7 @@
- Added `carthage.sh` to fix the issue with duplicated architecture when Carthage needs to build with Xcode 12.0
- Fixed Carthage issue to allow `Biometics` framework to be seperated from TABTestKit as the same of SwiftPM
- Fixed a timezone issue on TestExample when switching from Summer Time to Winter Time. We make sure that the DatePicker are now always in UTC Timezone
+- Added a method to assert the alert message
- Added assert for tab bar tab count
---
diff --git a/Example/TABTestKit/Base.lproj/Main.storyboard b/Example/TABTestKit/Base.lproj/Main.storyboard
index 5dc8dc24..3c908251 100644
--- a/Example/TABTestKit/Base.lproj/Main.storyboard
+++ b/Example/TABTestKit/Base.lproj/Main.storyboard
@@ -161,18 +161,25 @@
-
+
+
+
+
+
+
+
+
-
+
-
+
@@ -290,8 +297,8 @@
-
-
+
+
@@ -415,7 +422,7 @@
-
+
diff --git a/Example/TABTestKit/OtherElementsController.swift b/Example/TABTestKit/OtherElementsController.swift
index 5f374cb6..da88b628 100644
--- a/Example/TABTestKit/OtherElementsController.swift
+++ b/Example/TABTestKit/OtherElementsController.swift
@@ -73,6 +73,17 @@ final class OtherElementsController: UIViewController {
present(sheet, animated: true)
}
+ @IBAction func buttonAlertTapped() {
+ let alertController = UIAlertController(title: "Alert title", message: "Alert Message", preferredStyle: .alert)
+
+ let dismissAction = UIAlertAction(title: "Dismiss", style: .cancel, handler: { _ in
+ alertController.dismiss(animated: true)
+ })
+
+ alertController.addAction(dismissAction)
+
+ present(alertController, animated: true)
+ }
}
extension OtherElementsController: UITextFieldDelegate {
diff --git a/Example/TABTestKit_ExampleUITests/OtherElementsScreen.swift b/Example/TABTestKit_ExampleUITests/OtherElementsScreen.swift
index e960a439..31f721f8 100644
--- a/Example/TABTestKit_ExampleUITests/OtherElementsScreen.swift
+++ b/Example/TABTestKit_ExampleUITests/OtherElementsScreen.swift
@@ -16,6 +16,7 @@ struct OtherElementsScreen: Screen {
let scrollView = ScrollView(id: "MyScrollView") // In iOS 13, XCUI matches a hidden scroll view when the keyboard is showing :(
let label = Label(id: "Example label")
let button = Button(id: "Example button")
+ let alertButton = Button(id: "Alert button")
let segmentedControl = SegmentedControl(parent: View(id: "ExampleSegmentedControl"))
let textField = TextField(id: "ExampleTextField")
let numberPadTextField = TextField(id: "NumberPadTextField")
@@ -38,6 +39,7 @@ struct OtherElementsScreen: Screen {
let dateTimePicker = DatePicker(id: "ExampleDateTimePicker")
let countdownTimerPicker = DatePicker(id: "ExampleCountDownTimerPicker")
let shareSheet = ActivitySheet()
+ let alert = Alert(id: "Alert title", message: "Alert message", dismissButtonID: "Dismiss")
}
diff --git a/Example/TABTestKit_ExampleUITests/OtherElementsTests.swift b/Example/TABTestKit_ExampleUITests/OtherElementsTests.swift
index 4fee61cc..75fff1e0 100644
--- a/Example/TABTestKit_ExampleUITests/OtherElementsTests.swift
+++ b/Example/TABTestKit_ExampleUITests/OtherElementsTests.swift
@@ -40,6 +40,19 @@ final class OtherElementsTests: TABTestCase, SystemPreferencesContext {
And(I: see(otherElementsScreen))
}
+ Scenario("Asserting the alert message") {
+ Given(I: see(otherElementsScreen.alertButton))
+ And(I: tap(otherElementsScreen.alertButton))
+ Then(I: see(otherElementsScreen.alert))
+ And(the: message(in: otherElementsScreen.alert, is: "Alert message"))
+ }
+
+ Scenario("Dismissing the alert") {
+ Given(I: see(otherElementsScreen.alert))
+ When(I: tap(otherElementsScreen.alert.dismissButton))
+ Then(I: see(otherElementsScreen))
+ }
+
Scenario("Seeing and interacting with the segmented control") {
Given(I: see(otherElementsScreen.segmentedControl))
Then(I: tap(otherElementsScreen.segmentedControl.button(withID: "Second")))
diff --git a/README.md b/README.md
index 41f9b6cb..d12aab29 100644
--- a/README.md
+++ b/README.md
@@ -1485,6 +1485,11 @@ tap("OK", in: myScreen.alert)
Given(I: tap("OK", in: myScreen.alert))
```
+```swift
+message(in: myScreen.alert, is: "Alert message")
+
+Then(the: message(in: myScreen.alert, is: "Alert message"))
+```
#### SheetContext
diff --git a/TABTestKit/Classes/Contexts/AlertContext.swift b/TABTestKit/Classes/Contexts/AlertContext.swift
index dbb82044..31d6edd2 100644
--- a/TABTestKit/Classes/Contexts/AlertContext.swift
+++ b/TABTestKit/Classes/Contexts/AlertContext.swift
@@ -14,4 +14,7 @@ public extension AlertContext {
alert.actionButton(withID: actionButtonID).tap()
}
+ func message(in alert: Alert, is message: String) {
+ XCTAssertEqual(alert.message, message)
+ }
}
diff --git a/TABTestKit/Classes/Elements/Alert.swift b/TABTestKit/Classes/Elements/Alert.swift
index e5596074..938bda81 100644
--- a/TABTestKit/Classes/Elements/Alert.swift
+++ b/TABTestKit/Classes/Elements/Alert.swift
@@ -13,6 +13,7 @@ public struct Alert: Element {
public let id: String?
public let parent: Element
+ public let message: String?
public let type: XCUIElement.ElementType = .alert
public var dismissButton: Button {
return Button(id: dismissButtonID, parent: self)
@@ -20,8 +21,9 @@ public struct Alert: Element {
private let dismissButtonID: String
- public init(id: String?, parent: Element = App.shared, dismissButtonID: String = "Cancel") {
+ public init(id: String?, message: String? = nil, parent: Element = App.shared, dismissButtonID: String = "Cancel") {
self.id = id
+ self.message = message
self.parent = parent
self.dismissButtonID = dismissButtonID
}