[英]How can I perform a “swipe left” action via UI tests
How can I perform a "swipe left" action to trigger a segue and change view controller via UI tests in Xcode? 如何通过Xcode中的UI测试执行“向左滑动”操作以触发segue并更改视图控制器?
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".
以下代码将在标题为“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. 阅读有关
swipeLeft
以及您可以对元素执行的伴随手势的更多信息 。 If you are looking for a more general "cheat sheet", I've also got you covered . 如果您正在寻找更通用的“备忘单”,我也能为您提供帮助 。
If you can't swipeLeft
on app
如果你不能在
app
swipeLeft
app.swipeLeft()
try calling it on the scrollView
, like 尝试在
scrollView
上调用它,就像
app.scrollViews.element(boundBy: 0).swipeLeft()
无需知道UI堆栈上当前可用的UI元素,这对我app.windows.element(boundBy:0).swipeLeft()
: app.windows.element(boundBy:0).swipeLeft()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.