【问题标题】:How can I set the swipe distance when using '-[XCUIElement swipeDown]' in UITest with Xcode7在带有 Xcode7 的 UITest 中使用“-[XCUIElement swipeDown]”时如何设置滑动距离
【发布时间】:2016-07-05 14:10:11
【问题描述】:

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

【问题讨论】:

  • “滑动”不是滚动。它应该用于滑动识别器,而不是滚动。因此,您无法更改距离。滚动是 Apples UI 自动化的老痛点之一,但请参阅 stackoverflow.com/a/33538255/669586

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


【解决方案1】:

您可以下拉到坐标 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)

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

【讨论】:

  • 虽然这确实有效,但它看起来像滚动其未调整的文件。在您的回答中,您有 (CGVectorMake(0, 6),但在我的应用程序中,它看起来滚动 1 滚动太多。 coordinateWithNormalizedOffset 还有更多内容吗?也许我只是不知道它是如何工作的。
猜你喜欢
  • 2018-06-13
  • 2019-04-15
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-05-16
  • 1970-01-01
相关资源
最近更新 更多