I just started using EarlGrey, and now I try to realize construction which will make screenshot if the test fails on Assert.
It is rather simple, e.g. when I check if the keyboard is visible, because GREYKeyboard.waitForKeyboardToAppear()
returns 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
But if I want to check the same way if some element (for example, button or text field) I can't just use grey_sufficientlyVisible()
, and most of other matchers return non-Bool.
I know that .assert(with: )
exists, but it's not so versatile.
So, is there any way to make this working?