【问题标题】:iOS UI Automated Testing: How to pull down, drag or scroll in a CollectionView?iOS UI 自动化测试:如何在 CollectionView 中下拉、拖动或滚动?
【发布时间】:2014-04-09 15:55:20
【问题描述】:

我正在使用 UI 自动化测试框架测试我的应用程序。我有一个 UIACollectionView 我想下拉或拖动我的 CollectionView。我已经尝试了文档中的方法: 向上拖动

target.dragInsideWithOptions({startOffset:{x:0.5, y:0.9}, endOffset:{x:0.5, y:0.2}, duration:2.0});

或下拉:

target.dragInsideWithOptions({startOffset:{x:0.5, y:0.3}, endOffset:{x:0.5, y:0.8}, duration:2.0});

当这不起作用时,我尝试使用 UIAScrollView 的继承方法。 chatList 是我的 UIACollectionView

archivedChatCell = chatList.cells()["Noise"]
archivedChatCell.scrollToElementWithValueForKey(1, "isVisible")
chatList.scrollDown()
chatList.scrollToElementWithPredicate("Noise")

但屏幕上什么都没有。我在一些线程中读到这个 ​​(dragInsideWithOptions) 是一个 Apple 问题,需要为 iOS7 UI 测试修复。 有人知道问题是什么吗?我错过了什么还是有解决方法? 奇怪的是,我在我的应用程序的不同 CollectionView 中使用相同的代码,dragInsideWithOptions 工作正常,可以拖动或拉动屏幕。

谢谢你

【问题讨论】:

    标签: ios testing uicollectionview drag ui-automation


    【解决方案1】:

    是的,dragInsideWithOptions 和 flickInsideWithOptions 在模拟器上不起作用。但是,它们确实可以在真实设备上工作。因此,我的建议是在 Apple 解决问题之前使用真实设备。

    【讨论】:

    • 但就是这样,我让这个功能在其他屏幕上工作,这也是 CollectionViews。但只是不在我的 RootViewController 上,还有什么是 CollectionView...真的很奇怪的行为...??!!
    • 是的,这有点奇怪,但是您可以获取单元格数组以找到可以为您提供“当前单元格”的索引,然后使用 scrollToElementWithName遍历每个单元格> 方法,这可能会成功。
    猜你喜欢
    • 2017-03-01
    • 2023-03-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-05-29
    • 1970-01-01
    相关资源
    最近更新 更多