To write a UI Testcase for the first screen seems to be very simple.
As shown below.
func testExample() {
let app = XCUIApplication()
let textField = app.otherElements.containing(.navigationBar, identifier:"id").children(matching: .other).element.children(matching: .other).element.children(matching: .other).element.children(matching: .textField).element
textField.tap()
textField.tap()
app.navigationBars["id"].buttons["Done"].tap()
}
But how to write a test case , where one navigation controller triggers another screen as shown a below.
Navigation Controller -> UIViewController1 -> UIViewcontroller2 .....UIViewController5
To test the UIViewController5, I will have to write massive lines of code which will include the following logic
1) Launch the App.
2) Launch Controller1 ,perform the event to Launch Controller2
3) Repeat the step 2, till it reaches Controller5.
I belive the UI test case should be simple and should not take time.
What should be ideal approach in this case, as to run the test case for Controller5, it will have to execute all events before it?