简体   繁体   English

如何通过UI测试执行“向左滑动”操作

[英]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.

相关问题 在UI测试中执行完全向左滑动动作? - Perform a full swipe left action in UI Tests? UI Automation如何执行滑动手势 - UI Automation how to perform swipe gesture 如何禁用UITableView上的左右滑动手势 - How can I disable left and right swipe gestures on a UITableView 在移动设备上滑动(iPad设置屏幕)始终在右半部分滑动。 如何在左半部分执行滑动 - Swipe on mobile device (iPad Settings screen) always swipe on right half. How to perform Swipe in Left half 如何在swtableviewcell中执行滑动动作而不移动图像 - How to perform a swipe action in swtableviewcell with out moving the image 如何使用向左或向右滑动实现3D Touch预览操作? - How to implement 3D Touch preview action with left or right swipe? 如何在XCode 5中的每个“构建和运行”操作中自动执行单元测试? - How do I automatically perform unit tests on each “build and run” action in XCode 5? 如何实现左右滑动以在 swift IOS 中更改数据/视图? - How can I implement Swipe left and right to change data/views in swift IOS? 如何使用左右滑动手势来切换标签栏标签? - How can I switch tab bar tabs using left and right swipe gestures? UITableViewCell向右滑动以触发动作或执行检测 - UITableViewCell Swipe right to trigger action or perform segue
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM