使用 Xcode7 在 UITest 中使用“-[XCUIElement swipeDown]”时如何设置滑动距离

Chi*_*uck 1 objective-c ios xcode-ui-testing

XCUIElement.h类文件显示
- (void)scrollByDeltaX:(CGFloat)deltaX deltaY:(CGFloat)deltaY;
- (XCUICoordinate *)coordinateWithNormalizedOffset:(CGVector)normalizedOffset;功能。但这些不能在 iOS 设备上使用。XCUIElement.h提供- (void)swipeDown滑动tableview。因为向下滑动的距离不够,所以像MJRefresh这样的pull-to-refresh框架无法响应。
那么如何自定义位置或使用存在功能来编辑向下滑动的距离?

Joe*_*tti 5

您可以下拉到坐标 API 以执行下拉刷新。

let firstCell = app.staticTexts["Cell One"]
let start = firstCell.coordinateWithNormalizedOffset(CGVectorMake(0, 0))
let finish = firstCell.coordinateWithNormalizedOffset(CGVectorMake(0, 6))
start.pressForDuration(0, thenDragToCoordinate: finish)
Run Code Online (Sandbox Code Playgroud)

我在我的博客上汇总了更多信息以及一个工作示例应用程序