How can I perform a "swipe left" action to trigger a segue and change view controller via UI tests in Xcode?
The recorded code is
[[[[[[[XCUIApplication alloc] init].otherElements containingType:XCUIElementTypeNavigationBar identifier:@"UIView"] childrenMatchingType:XCUIElementTypeOther].element childrenMatchingType:XCUIElementTypeOther].element childrenMatchingType:XCUIElementTypeOther].element tap];
but it seems that it doesn't work -- as far as I see, view controller doesn't change to the new one.
It is hard to tell exactly which view you are trying to swipe. The following code will perform the "swipe left" gesture on a label titled "Swipe Me". Once you target your view it should be easy to follow the same technique.
XCUIApplication *app = [XCUIApplication alloc] init];
[app.labels[@"Swipe Me"] swipeLeft];
Read more about swipeLeft
and the accompanying gestures you can perform on elements. If you are looking for a more general "cheat sheet", I've also got you covered.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With