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

时间:2016-07-05 14:10:11

标签: ios objective-c xcode-ui-testing

XCUIElement.h类文件显示
- (void)scrollByDeltaX:(CGFloat)deltaX deltaY:(CGFloat)deltaY;
- (XCUICoordinate *)coordinateWithNormalizedOffset:(CGVector)normalizedOffset;功能。但这些不能在iOS设备上使用。 XCUIElement.h提供- (void)swipeDown来刷表格视图。由于滑动距离不足,因此不能像MJRefresh那样响应刷新框架。
那么如何自定义位置或使用存在功能来编辑向下滑动距离?

1 个答案:

答案 0 :(得分:4)

您可以下拉到坐标API以执行pull-to-refresh。

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)

我已将more informationworking sample app放在我的博客上。