1

I'm using EarlGreyfor automated UI testing on an iOS project. I want to check whether the keyboard is shown or not after swiping away on the screen.

I've seen the header file in EarlGrey framework named GREYKeyboard.h with a function named isKeyboardShown with a bool return value. This would be very helpful for me, but I don't know how to use it since I have no access to this API.

EarlGrey is installed with Carthage.

S.Boy
  • 21
  • 4

2 Answers2

1

I've found the solution. You can access to GREYKeyboard.h (which is a private header) by editing the module.modulemap file. Add the

header "../PrivateHeaders/GREYKeyboard.h"

line to the file. The module.modulemap file should look like this after editing:

 framework module EarlGrey {
  umbrella header "EarlGrey.h"

  header "../PrivateHeaders/GREYKeyboard.h"
  export *
  module * { export * }
}
S.Boy
  • 21
  • 4
0

You include the GREYKeyboard.h header and do this:

if (GREYKeyboard.isKeyboardShown) {
    ; // the keyboard is showing
}
else {
    ; // it's not
}
Shebuka
  • 3,148
  • 1
  • 26
  • 43
  • Could you please give me more information on how to include the GREYKeyboard. h header? – S.Boy Sep 20 '17 at 13:38
  • @S.Boy do you have `import EarlGrey` at the top of your swift file? – NSGangster Sep 20 '17 at 14:45
  • Of course, but I still do not have access to GREYKeyboard, but for example I have access to GREYInteractions. I think I have to add the GREYKeyboard header extra, but I don't know how to do that. – S.Boy Sep 20 '17 at 16:05
  • add `#import ` before [this line](https://github.com/google/EarlGrey/blob/931aa8c6edf2f6cfb1ccf76adcbadf6621bc5711/EarlGrey/EarlGrey.h#L57) – Shebuka Sep 20 '17 at 16:53
  • GREYKeyboard is private so you shouldn't just import it directly. Remember, with EarlGrey you can also check for the existence of individual keyboard keys as well, such as grey_text(@"Return"). – gran_profaci Sep 20 '17 at 18:23
  • Unfortunately the #import didn't work. I've already developed a workaround, but I really want to use the GREYKeyboard. Can I have access to it despite it's a private header? – S.Boy Sep 21 '17 at 08:27