Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pressing back button (backBarButtonItem) in KIF?

Does KIF provide any special support for tapping back buttons or will I have to do something like this?

// in parent ViewController

self.navigationItem.backBarButtonItem.isAccessibilityElement = YES;
self.navigationItem.backBarButtonItem.accessibilityLabel     = @"Back";

// in test class

[tester tapViewWithAccessibilityLabel: @"Back"]];

The latter would be a bit unfortunate, because my code currently does not have back buttons at all and self.navigationItem.backBarButtonItem is and can normally remain nil (see here): the description in the storyboard suffices so far.

like image 500
Drux Avatar asked Sep 05 '25 22:09

Drux


1 Answers

By default, the back button will be labeled "Back" and accessible to VoiceOver as such as well so:

[tester tapViewWithAccessibilityLabel: @"Back"];

will work if you haven't done anything else.

So assuming I understand the structure of your view controllers (which is navigation, but with no explicit backBarButtonItem set), then what you have should work without the parent view controller changes you're worried about.

like image 167
plluke Avatar answered Sep 09 '25 00:09

plluke