I'm new to writing Integration Tests with Subliminal. And I want to test if a certain View Controller is shown after the user taps a button. What would the best way to test this?
- Can I get the top most view controller with Subliminal and find it's title?
- Can I get the top most view controller and compare its class?
- Can I the title label of the Navigation Controller?
At the moment I only managed to get the title label of the Navigation Controller by its accessibility label, like this:
SLElement *titleLabel = [SLElement elementWithAccessibilityLabel:@"Welcome"];
SLAssertTrue([[UIAElement(titleLabel) label] isEqualToString:@"Welcome"], @"It should show the Welcome screen");
But then I would just be testing if @"Welcome" == @"Welcome"
. And a welcome label might appear in the view hierarchy of other view controllers as well.
What would be your approach to test and assert if the View Controller shown after a user's action is indeed the view controller that I am expecting?
Thanks!