0

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?

gran_profaci
  • 8,087
  • 15
  • 66
  • 99
N13
  • 91
  • 7
  • Sorry, what are you trying to assert again? If the keyboard is Visible? – gran_profaci Nov 09 '17 at 20:01
  • @gran_profaci , That was the example which works, because `waitForKeyBoardToAppear` returns Bool. I'm trying to assert the visibility of different elements (like buttons and text fields). – N13 Nov 10 '17 at 06:22

0 Answers0