ios - 界面测试失败 : Multiple Matches Found Error

标签 ios swift uitableview swift3 xcode-ui-testing

尝试使用 XCode 执行 UI Testing 时。我有 UITableView 具有多个相同类型的匹配项。无论如何我可以在任何相同类型的单元格上随机点击()而不提供 elementBoundByIndex(0) 来选择特定的单元格。

let firstButton = accordianButtonsQuery.elementBoundByIndex(0)
firstButton.tap()

最佳答案

您可以生成一个介于 0 和匹配查询的元素的 count 之间的随机索引,并将其与 elementBoundByIndex 一起使用,但您不能只让 tap 执行在随机元素上。

手势需要特定的元素作为目标。这应该会提示您从测试中删除随机性,使它们具有确定性并因此可预测。将随机性引入测试会使其变得不可预测、难以调试,并且可能变得脆弱/不稳定。

关于ios - 界面测试失败 : Multiple Matches Found Error,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40745273/

相关文章:

ios - iOS 上的电容器 : POST request fails

ios - 为什么在创建项目范围的常量时需要实现文件 (.m)?

ios - 如何从 Xcode 项目中正确删除 Parse 及其框架?

ios - 在编辑模式下将图像添加到 UITableViewCell 未正确对齐

ios - 舍入 UITableViewCell

ios - 无法以编程方式注册在 UIViewController 中创建的 TableView 的 TableCell

ios - 无法修改 SKSpriteNodes 的 objectAtIndex NSMutableArray

ios - 3D touch quick actions preview view controller 只有一次

swift - 如何在使用 servicestack swift 插件向 servicestack web api 发布请求时添加 http header ?

ios - 推送通知内的文本倒计时器