如何通过
Xcode中的UI测试执行“向左滑动”操作以触发segue并更改视图控制器?
录制的代码是
[[[[[[[XCUIApplication alloc] init].otherElements containingType:XCUIElementTypeNavigationBar identifier:@"UIView"] childrenMatchingType:XCUIElementTypeOther].element childrenMatchingType:XCUIElementTypeOther].element childrenMatchingType:XCUIElementTypeOther].element tap];
但似乎它不起作用 – 据我所知,视图控制器不会更改为新的.
解决方法
很难准确判断您要尝试滑动的视图.以下代码将在标题为“Swipe Me”的标签上执行“向左滑动”手势.定位视图后,应该很容易遵循相同的技术.
XCUIApplication *app = [XCUIApplication alloc] init]; [app.labels[@"Swipe Me"] swipeLeft];
Read more about swipeLeft
以及您可以对元素执行的伴随手势.如果你正在寻找一个更通用的“备忘单”,我也是got you covered.