S.Boy
S.Boy

Reputation: 21

How to check whether the keyboard is shown or not?

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.

Upvotes: 1

Views: 777

Answers (2)

S.Boy
S.Boy

Reputation: 21

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 * }
}

Upvotes: 1

Shebuka
Shebuka

Reputation: 3228

You include the GREYKeyboard.h header and do this:

if (GREYKeyboard.isKeyboardShown) {
    ; // the keyboard is showing
}
else {
    ; // it's not
}

Upvotes: 0

Related Questions