如何在元素的存在/可见性检查中使用GreyAssert?

时间:2017-11-09 14:43:57

标签: xcode-ui-testing earlgrey

我刚刚开始使用EarlGrey,现在我尝试实现构建,如果测试在Assert上失败,将进行截屏。 它很简单,例如当我检查键盘是否可见时,因为GREYKeyboard.waitForKeyboardToAppear()返回Bool:

let image = GREYScreenshotUtil.takeScreenshot()
GREYScreenshotUtil.saveImage(asPNG: image, toFile: "\(testMethodName).png", inDirectory: path/to/necessary/directory)
GreyAssert(GREYKeyboard.waitForKeyboardToAppear(), "Keyboard is not active")  //works correct

但是如果我想以相同的方式检查某个元素(例如,按钮或文本字段)我不能只使用grey_sufficientlyVisible(),并且大多数其他匹配器返回非Bool。

我知道.assert(with: )存在,但它并不是那么多才多艺。 那么,有什么方法可以让它发挥作用吗?

0 个答案:

没有答案