Search code examples
iosui-automationearlgrey

How can I get EarlGrey to select the keyboard's window or other private UIKit elements?


I am trying to write a test to automate the showing and hiding of the UI keyboard. However, I need to make sure that the keyboard is visible on the screen whenever I try to make such a call. I found that I can check for an element of the UIRemoteKeyboardWindow class to do so, but how do I get EarlGrey to match it since there's no direct unique matcher for it. Is there any way with EarlGrey by which you can match on these internal elements?


Solution

  • From the FAQ:

    How do I create a matcher that matches internal UIKit classes?

    Use NSClassFromString to match on internal classes that can't be referenced directly.

    grey_kindOfClass(NSClassFromString("_UIAlertControllerView"))